aboutsummaryrefslogtreecommitdiff
path: root/static/sw.js
diff options
context:
space:
mode:
authorJieiku2023-08-20 22:37:18 -0700
committerJieiku2023-08-20 22:37:18 -0700
commit61f2e1c3ac343163a5361686ad529c7039387310 (patch)
tree4be20065b86c9378cae2fe3f6de7079c3e3b2d3d /static/sw.js
parent4a9479325f07b1f73673cf95c1891229de9450dc (diff)
downloadabridge-61f2e1c3ac343163a5361686ad529c7039387310.tar.gz
abridge-61f2e1c3ac343163a5361686ad529c7039387310.tar.bz2
abridge-61f2e1c3ac343163a5361686ad529c7039387310.zip
fix image shortcodes for multilingual, and other optimizations
Diffstat (limited to 'static/sw.js')
-rw-r--r--static/sw.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/static/sw.js b/static/sw.js
index 4a2b0db..7d07a13 100644
--- a/static/sw.js
+++ b/static/sw.js
@@ -14,6 +14,8 @@ class Pwa {
// 3600=1hour, 28800=8hours, 86400=1day, 604800=1week, 1209600=2weeks
this.NORM_TTL = 86400;// html, json, xml, anything else undefined
this.LONG_TTL = 604800;// js, css
+ // keep the ttl on these lower:
+ this.TTL_NORM = ["sw.min.js", "sw_load.min.js"];
// rarely change, may be a good idea to periodically refresh, incase I change these and forget to increment service worker version:
this.TTL_LONG = ["js", "css"];
// never change, cache forever unless service worker version is incremented:
@@ -33,10 +35,20 @@ class Pwa {
const extension = url.split('.').reverse()[0].split('?')[0];
return (extension.endsWith('/')) ? '/' : extension;
}
+ getFileName(url) {
+ const filename = url.substring(url.lastIndexOf('/') + 1).split('?')[0];;
+ return (filename.endsWith('/')) ? '/' : filename;
+ }
getTTL(url) {
if (typeof url === 'string') {
const extension = this.getFileExtension(url);
+ const filename = this.getFileName(url);
+
+ if (this.TTL_NORM.indexOf(filename) > -1) {
+ //console.info(url + ' contains a TTL_NORM filename');
+ return this.NORM_TTL;
+ }
if (this.TTL_LONG.indexOf(extension) > -1) {
//console.info(url + ' contains a TTL_LONG extension');
return this.LONG_TTL;
@@ -45,6 +57,7 @@ class Pwa {
//console.info(url + ' contains a TTL_EXEMPT extension');
return null;
}
+ //console.info(url + ' TTL_NORM');
return this.NORM_TTL;
}
return null;