I have implemented a service worker for my website. However I am not sure about the expiration setting on this.
Am currently using Nextjs for page rendering and Workbox with Apollo for data mangement. My Workbox config:
// File to generate the service worker.
require("dotenv").config()
const workboxBuild = require("workbox-build")
const { COUNTRY: country, NODE_ENV } = process.env
const urlPattern = new RegExp(`/${country}\/static\/.*/`)
// https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-build#.generateSW
const buildSW = () => {
return workboxBuild.generateSW({
swDest: "public/workbox-worker.js",
clientsClaim: true,
mode: NODE_ENV,
skipWaiting: true,
sourcemap: false,
runtimeCaching: [
{
urlPattern: urlPattern,
// Apply a cache-first strategy.
handler: "CacheFirst",
options: {
cacheName: "Static files caching",
expiration: {
maxEntries: 50,
maxAgeSeconds: 3600,
},
},
},
],
})
}
buildSW()
My service worker is installed and activated and has started caching files.
My only question is shouldn't the max age here be 3600? Or am I doing something wrong?