How to cache webpack's assets and exclude index.html?

Viewed 1212

I want to optimize my SPA to cache all of webpack's assets so they load faster on next reload.

I don't need offline capabilities and I want the users to always be served the new versions on as soon as they reload the page, no "New content is available; please refresh." message.

For what I understand, Webpack is including hashes in the name of each files so file names are "unique" from one version to another. So my strategy is to cache everything besides index.html. So when a user hits reload, he always gets the index.html from the server and then service workers serves cache for already loaded files.

Put simply, I am looking to replicate a simple caching like with header Cache-Control.

Should I use the workbox-webpack-plugin and the GenerateSW(config) method ? How to configure it to exclude only index.html from the cache and include everything else ?

1 Answers
Related