I'm trying to make a very basic PWA with a service worker using Workbox but I have a problem. I'm using the command line interface to generate the service worker, everything works, perfect lightscore but I can't add my index.html to the runtime caching. I have to add it to the global patterns so that my website works in offline mode but then when I update my index.html file it doesn't get updated unless I clear my cache. I want the same thing as my js and css. When I upgrade those files they get updated. Here is my workbox configuration file:
module.exports = {
globDirectory: "./",
globPatterns: ["**/*.{html,json}"],
swDest: "./serviceworker.js",
// Define runtime caching rules.
runtimeCaching: [
{
// Match any request that ends with .png, .jpg, .jpeg or .svg. urlPattern: /\.(?:png|jpg|jpeg|svg)$/,
urlPattern: /\.(?:png|jpg|jpeg|svg)$/,
// Apply a network-first strategy.
handler: "NetworkFirst",
options: {
// Use a custom cache name.
cacheName: "images",
},
},
{
urlPattern: /\.(?:js|css)$/,
handler: "NetworkFirst",
options: {
cacheName: "main",
},
},
],
};