Remove cache option, use build.ssr.cache instead

This commit is contained in:
Sébastien Chopin 2017-05-21 15:13:19 +02:00
parent 054df82200
commit 14c3c07d57
7 changed files with 15 additions and 14 deletions

View File

@ -1,3 +1,10 @@
module.exports = { module.exports = {
cache: true build: {
ssr: {
cache: require('lru-cache')({
max: 1000,
maxAge: 1000 * 60 * 15
})
}
}
} }

View File

@ -1,6 +1,7 @@
{ {
"name": "nuxt-cached-components", "name": "nuxt-cached-components",
"dependencies": { "dependencies": {
"lru-cache": "^4.0.2",
"nuxt": "latest" "nuxt": "latest"
}, },
"scripts": { "scripts": {

View File

@ -0,0 +1,5 @@
module.exports = {
generate: {
minify: false
}
}

View File

@ -490,16 +490,7 @@ function webpackRunServer () {
function createRenderer (bundle, manifest) { function createRenderer (bundle, manifest) {
// Create bundle renderer to give a fresh context for every request // Create bundle renderer to give a fresh context for every request
let cacheConfig = false
if (this.options.cache) {
this.options.cache = (typeof this.options.cache !== 'object' ? {} : this.options.cache)
cacheConfig = require('lru-cache')(_.defaults(this.options.cache, {
max: 1000,
maxAge: 1000 * 60 * 15
}))
}
this.renderer = createBundleRenderer(bundle, Object.assign({ this.renderer = createBundleRenderer(bundle, Object.assign({
cache: cacheConfig,
clientManifest: manifest, clientManifest: manifest,
runInNewContext: false, runInNewContext: false,
inject: false, inject: false,

View File

@ -30,7 +30,6 @@ class Nuxt {
layouts: {}, layouts: {},
serverMiddleware: [], serverMiddleware: [],
ErrorPage: null, ErrorPage: null,
cache: false,
loading: { loading: {
color: 'black', color: 'black',
failedColor: 'red', failedColor: 'red',

View File

@ -59,7 +59,6 @@
"babel-preset-es2015": "^6.24.1", "babel-preset-es2015": "^6.24.1",
"babel-preset-vue-app": "^1.2.0", "babel-preset-vue-app": "^1.2.0",
"chokidar": "^1.7.0", "chokidar": "^1.7.0",
"co": "^4.6.0",
"compression": "^1.6.2", "compression": "^1.6.2",
"connect": "^3.6.2", "connect": "^3.6.2",
"css-loader": "^0.28.1", "css-loader": "^0.28.1",
@ -73,7 +72,6 @@
"html-minifier": "^3.5.0", "html-minifier": "^3.5.0",
"html-webpack-plugin": "^2.28.0", "html-webpack-plugin": "^2.28.0",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"lru-cache": "^4.0.2",
"memory-fs": "^0.4.1", "memory-fs": "^0.4.1",
"offline-plugin": "^4.7.0", "offline-plugin": "^4.7.0",
"opencollective": "^1.0.3", "opencollective": "^1.0.3",

View File

@ -3878,7 +3878,7 @@ lru-cache@^3.2.0:
dependencies: dependencies:
pseudomap "^1.0.1" pseudomap "^1.0.1"
lru-cache@^4.0.0, lru-cache@^4.0.1, lru-cache@^4.0.2: lru-cache@^4.0.0, lru-cache@^4.0.1:
version "4.0.2" version "4.0.2"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.2.tgz#1d17679c069cda5d040991a09dbc2c0db377e55e" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.2.tgz#1d17679c069cda5d040991a09dbc2c0db377e55e"
dependencies: dependencies: