Browse Source

add version number to cache names

main
James Fenn 3 months ago
parent
commit
3734163bba
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      meta/sw.js.njk

+ 4
- 2
meta/sw.js.njk View File

@@ -4,6 +4,8 @@ eleventyExcludeFromCollections: true
---
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.6.1/workbox-sw.js');

const _version = '-1';

if (workbox) {
workbox.precaching.precacheAndRoute([]);

@@ -35,7 +37,7 @@ if (workbox) {
// Cache CSS files
/.*\.css/,
workbox.strategies.staleWhileRevalidate({
cacheName: 'css-cache',
cacheName: 'css-cache' + _version,
})
);

@@ -43,7 +45,7 @@ if (workbox) {
// Cache image files
/.*\.(?:png|jpg|jpeg|svg|gif)/,
workbox.strategies.cacheFirst({
cacheName: 'image-cache',
cacheName: 'image-cache' + _version,
plugins: [
new workbox.expiration.Plugin({
maxEntries: 100,


Loading…
Cancel
Save