New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I cache pages? #4698
Comments
Can anyone help me? |
Hey there, try and take a look at |
@mavrick no,not component-cache, i need page-cache
|
I use a custom server but I am not very happy with it - gonna rewrite it tonight :D cause I want to use brotli and compression only allows gzip :( import { Nuxt } from 'nuxt'
import compression from 'compression'
import express from 'express'
import apicache from 'apicache'
import config from './nuxt.config'
config.dev = false
const cache = apicache.options({
headers: {
'cache-control': 'no-cache'
}
}).middleware
const cacheSuccesses = cache('12 hours', (req, res) => res.statusCode === 200)
// => create nuxt for using the nuxt.render-function
const nuxt = new Nuxt(config)
// => create express app
const app = express()
const port = 3000
app.get('/api/cache/index', (req, res) => {
res.json(apicache.getIndex())
})
app.use(compression())
app.use(cacheSuccesses)
app.use(nuxt.render)
app.listen(port, '0.0.0.0', () => {
console.log('Server listening on `localhost:' + port + '`.')
}) |
@fmoessle regarding Brotli: There is a workaround for that (read my blog post about Nuxt.js on Brotli). @clarkdo already submitted a PR for Brotli support in compression as the native support landed in node. Ideally, you should use a reverse proxy like NGINX or a CDN like Cloudflare to encode the files with Brotli |
@manniL I already implemented it as you described in your blogpost. Thanks :) |
Found a nuxt module for page level cache, hope it can help you https://github.com/arash16/nuxt-ssr-cache |
Thanks!!! |
here is the new solution for cache the whole page even you can cache consistent api like menu if you need https://www.npmjs.com/package/nuxt-perfect-cache
|
What problem does this feature solve?
Page-level Caching
What does the proposed changes look like?
I have read:
and the doc see:
This method should be used mostly for test purposes as well with nuxt.renderAndGetWindow.
look like the method
nuxt.renderRoute
just for testso, what should I do for caching page ?
I create a question to cmtp, but on one reply... so I create this issue, please tell me how can i do, thanks!
The text was updated successfully, but these errors were encountered: