nuxt-ssr-cache
Cache middleware for nuxt's SSR rendering.
Setup
npm install nuxt-ssr-cache
or
yarn add nuxt-ssr-cache
then inside your nuxt.config.js
add cache config:
module.exports = {
version: pkg.version,
modules: [
'nuxt-ssr-cache',
],
cache: {
useHostPrefix: false,
pages: [
'/page1',
'/page2',
/^\/page3\/\d+$/,
/^\/$/
],
key(route, context) {
},
store: {
type: 'memory',
max: 100,
ttl: 60,
},
},
};
redis
store
module.exports = {
cache: {
store: {
type: 'redis',
host: 'localhost',
ttl: 10 * 60,
configure: [
['maxmemory', '200mb'],
['maxmemory-policy', 'allkeys-lru'],
],
},
},
}
Uses cache-manager-redis under the hood.
memcached
store
module.exports = {
cache: {
store: {
type: 'memcached',
options: {
hosts: ['127.0.0.1:11211'],
},
},
},
}
Uses cache-manager-memcached-store under the hood.
multi
cache (layered)
module.exports = {
cache: {
store: {
type: 'multi',
stores: [
{ type: 'memory', },
{ type: 'redis', },
],
},
},
}
License
MIT