All Projects → thinkjs → Think Html Cache

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
Hioshop Admin
海风小店,开源商城,微信小程序商城管理后台,后台管理,VUE
Stars: ✭ 452 (+7433.33%)
Mutual labels:  thinkjs
harpers
A forum app written by node & thinkJS
Stars: ✭ 12 (+100%)
Mutual labels:  thinkjs
think-cli
ThinkJS 3.x command line tool
Stars: ✭ 37 (+516.67%)
Mutual labels:  thinkjs
think-pagination
Pagination for ThinkJS 3 & 2
Stars: ✭ 13 (+116.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
online-mall
一个全栈的在线商城示例,包括了管理后台的前端与后端,微信小程序和对应的接口后端
Stars: ✭ 95 (+1483.33%)
Mutual labels:  thinkjs
Hioshop Server
海风小店,开源商城,微信小程序商城服务器端
Stars: ✭ 331 (+5416.67%)
Mutual labels:  thinkjs
structure-admin
技术栈:nodeJS+vue+vuex+mysql+redis,前端使用vue的element-ui的组件库,后端使用nodeJS的服务,数据库mysql,缓存使用的还redis
Stars: ✭ 45 (+650%)
Mutual labels:  thinkjs
thinkjsplus
thinkjs3.0 从入门到实战
Stars: ✭ 100 (+1566.67%)
Mutual labels:  thinkjs
hawk-eye
前端监控:定时监控站点渲染情况,记录异常并保存截图: puppeteer, thinkjs,mongodb,headless-chrome,vuejs
Stars: ✭ 88 (+1366.67%)
Mutual labels:  thinkjs
cicada
Favorite article collections system
Stars: ✭ 91 (+1416.67%)
Mutual labels:  thinkjs
My Bookmark
在线书签管理工具
Stars: ✭ 481 (+7916.67%)
Mutual labels:  thinkjs
Www.thinkjs.org
ThinkJS website
Stars: ✭ 171 (+2750%)
Mutual labels:  thinkjs
think-model
Default model for ThinkJS 3.x
Stars: ✭ 16 (+166.67%)
Mutual labels:  thinkjs
Hioshop Miniprogram
海风小店,开源商城,微信小程序商城
Stars: ✭ 779 (+12883.33%)
Mutual labels:  thinkjs
Nideshop
NideShop 开源微信小程序商城服务端 API(Node.js + ThinkJS)
Stars: ✭ 5,154 (+85800%)
Mutual labels:  thinkjs
think-sequelize
Sequelize Extend for ThinkJS 3.x
Stars: ✭ 13 (+116.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].