Usage

Learn how to use the cache module in your Nuxt 3 application.

Browser

Let's imagine that our project consits of three pages (home, product, category) that we would like cache headers to be applied to. We could then define them inside browser.pages with appriopriate cache headers and directives.

You can read more about directives here

export default {
  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 }]
        ]
      },
    }]
  ],
}

This will result in following Cache-Control headers in the response of each page. You can check it out in the browser.

Server

Coming soon