eleventy-plugin-pwa icon indicating copy to clipboard operation
eleventy-plugin-pwa copied to clipboard

network-first strategy

Open mvolkmann opened this issue 4 years ago • 1 comments

Is there a way to tell workbox that you want it to use the network-first strategy so it always attempts to load files from the network before getting them from the cache? It seems like this would be desirable while making changes to a site.

mvolkmann avatar Apr 11 '20 21:04 mvolkmann

You can change the Workbox Strategy by adding the following to your .eleventy.js file:

eleventyConfig.addPlugin( pluginPWA, {
	runtimeCaching: [
		{
			urlPattern: /^.*\.(html|jpg|png|gif|webp|ico|svg|woff2|woff|eot|ttf|otf|ttc|json)$/,
			handler: 'NetworkFirst'
		},
		{
			urlPattern: /^https?:\/\/fonts\.googleapis\.com\/css/,
			handler: 'NetworkFirst'
		}
	]
});

Same with any default options listed here:

https://github.com/okitavera/eleventy-plugin-pwa/blob/master/src/builder.js

thedigitalman avatar Sep 10 '21 14:09 thedigitalman