As of Nuxt 3.rc-12 you can use routeRoules so this module is now deprecated. Please use official Nuxt approach
Browser and Server Cache module for Nuxt 3
yarn add @nuxt-modules/cache # yarn
npm i @nuxt-modules/cache # npm
Firstly, you need to add @nuxt-modules/cache to your Nuxt config.
// nuxt.config.js
{
buildModules: [
[
'@nuxt-modules/cache',
{
browser: {
pages: [
['/', { 'max-age': 3600, 'stale-when-revalidate': 10 }],
['/product', { 'max-age': 3600, 'stale-when-revalidate': 10 }],
['/category', { 'max-age': 3600, 'stale-when-revalidate': 10 }]
]
}
}
]
]
}
And that’s it! The module is registered and now your pages will have cache-control headers applied.
For more configuration options, please visit the docs
Configuration of server cache will be added in the next versions.
yarn install or npm installyarn dev or npm run devWe use cookies
We use cookies to analyze traffic and improve your experience. You can accept or reject analytics cookies.