Custom Caching Strategy with next-pwa #259
Answered
by
kennethstarkrl
1mehdifaraji
asked this question in
Q&A
-
How can I use a specific caching strategy with next pwa ? For example I use it like this : const withPWA = require("next-pwa"); module.exports = withPWA({ How can I use the network first caching strategy with next-pwa ? |
Beta Was this translation helpful? Give feedback.
Answered by
kennethstarkrl
Dec 18, 2021
Replies: 1 comment
-
runtimeCaching takes an array of caching strategies objects, passed the example one from cache.js 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
}
}
},
]
},
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
1mehdifaraji
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.