diff options
| -rw-r--r-- | config.toml | 2 | ||||
| -rw-r--r-- | package_abridge.js | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/config.toml b/config.toml index 4e448e7..19559cb 100644 --- a/config.toml +++ b/config.toml @@ -262,6 +262,8 @@ pwa_cache_all = true ### List of Files for the PWA to initially Cache, used if pwa_cache_all = false pwa_BASE_CACHE_FILES = "'/js/theme.min.js','/js/theme_light.min.js','/abridge.css','/js/abridge.min.js','/','/404.html','/offline/','/manifest.min.json'" +pwa_IGNORE_FILES = ["_headers","sw.min.js","sw.js"] +#pwa_IGNORE_FILES = ["_headers","sw.min.js","sw.js","android-chrome-192x192.png","android-chrome-512x512.png","apple-touch-icon.png","favicon-16x16.png","favicon-32x32.png","favicon.ico","m48.png","m72.png","m96.png","m128.png","m192.png","m384.png","m512.png","m1024.png","mstile-150x150.png"] ############################################################################### ### Favicons, comment out a line to disable loading some or all of these if needed. diff --git a/package_abridge.js b/package_abridge.js index 908c9be..e82eee8 100644 --- a/package_abridge.js +++ b/package_abridge.js @@ -30,6 +30,7 @@ const pwa_TTL_LONG = data.extra.pwa_TTL_LONG; const pwa_TTL_EXEMPT = data.extra.pwa_TTL_EXEMPT; const pwa_cache_all = data.extra.pwa_cache_all; const pwa_BASE_CACHE_FILES = data.extra.pwa_BASE_CACHE_FILES; +const pwa_IGNORE_FILES = data.extra.pwa_IGNORE_FILES; // This is used to pass arguments to zola via npm, for example: // npm run abridge -- "--base-url https://abridge.pages.dev" @@ -159,8 +160,12 @@ async function abridge() { // format output item = "/" + file.replace(/index\.html$/i, '');// strip index.html from path item = item.replace(/\\/g, '/');// replace backslash with forward slash for Windows - item = item.replace(/^\/sw(\.min)?\.js/i, '');// dont cache service worker - item = item.replace(/^\/_headers/i, '');// dont cache the cloudflare _headers file + + var arrayLength = pwa_IGNORE_FILES.length; + for (var i = 0; i < arrayLength; i++) { + regex = new RegExp(`^\/${pwa_IGNORE_FILES[i]}`, `i`); + item = item.replace(regex, '');// dont cache files in the pwa_IGNORE_FILES array + } // if formatted output is not empty line then append it to cache var if (item != '') {// skip empty lines |
