thinkjs / Think Html Cache
Licence: mit
html-cache middleware for ThinkJS 2.0
Programming Languages
javascript
184084 projects - #8 most used programming language
Labels
Projects that are alternatives of or similar to Think Html Cache
Thinkjs Vue.js Blog
使用 ThinkJS+Vue.js+mysql 开发的博客程序,演示地址:
Stars: ✭ 190 (+3066.67%)
Mutual labels: thinkjs
animaris
Documentation and Mock for JSBridge base on ThinkJS & MongoDB & React & Antd.
Stars: ✭ 28 (+366.67%)
Mutual labels: thinkjs
Firekylin
A Simple & Fast Node.js Blogging Platform Base On ThinkJS3 & React & ES2015+
Stars: ✭ 1,804 (+29966.67%)
Mutual labels: thinkjs
Thinkjs
Use full ES2015+ features to develop Node.js applications, Support TypeScript.
Stars: ✭ 5,255 (+87483.33%)
Mutual labels: thinkjs
structure-admin
技术栈:nodeJS+vue+vuex+mysql+redis,前端使用vue的element-ui的组件库,后端使用nodeJS的服务,数据库mysql,缓存使用的还redis
Stars: ✭ 45 (+650%)
Mutual labels: thinkjs
hawk-eye
前端监控:定时监控站点渲染情况,记录异常并保存截图: puppeteer, thinkjs,mongodb,headless-chrome,vuejs
Stars: ✭ 88 (+1366.67%)
Mutual labels: thinkjs
think-html-cache
html-cache middleware for ThinkJS 2.0
Install
npm install think-html-cache
How to use
register middleware
create file is not exist, src/common/bootstrap/middleware.js
import htmlCache from 'think-html-cache';
think.middleware('html_cache', htmlCache);
hook config
src/common/config/hook.js
export default {
logic_before: ['prepend', 'html_cache'],
view_after: ['append', 'html_cache']
}
html_cache config
create file is not exist src/common/config/html_cache.js
:
export default {
on: true, //use html_cache
type: 'base', //cache content store type
timeout: 0,
callback: function(key){
return think.md5(key);
},
rules: {
'home/index/index': ['index_{page}', timeout, callback],
'index/detail': ['index_{id}', timeout, callback]
},
//adapter config
adapter: {
file: {
path: think.getPath('common', 'runtime') + '/html_cache' //when type is file, set cache path
}
}
}
type
cache content store type, support base
& file
.
timeout
expire time, if value is 0
, only expired when template is updated.
callback
encrypt cache key, such as:
function (key) {
return think.md5(key);
}
rules
cache rules, key is [module]/[controller]/[action]
.
can get paramters in rule:
'index_{page}' // get page paramter from GET
'index_{:module}' // get module value
'index_{:controller}' //get controller value
'index_{:action}' //get action value
'index_{cookie.xxx}' //get value from cookie
LICENSE
MIT
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].