Skip to content

Custom Caching Strategy with next-pwa #259

Discussion options

You must be logged in to vote

runtimeCaching takes an array of caching strategies objects, passed the example one from cache.js
Took me a bit to figure this out, hope it helps.

module.exports = withPWA({
    pwa:{
      dest:'public',
      runtimeCaching: [
        {
          urlPattern: /\.(?:json|xml|csv)$/i,
          handler: 'NetworkFirst',
          options: {
            cacheName: 'static-data-assets',
            expiration: {
              maxEntries: 32,
              maxAgeSeconds: 24 * 60 * 60 // 24 hours
            }
          }
        },
      ]
    },
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by 1mehdifaraji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants