Fossil SCM

Automatically randomize the names of the "pikchr.js" and "pikchr.wasm" files after "make wasm", to force browser cache reloads.

drh 2025-03-05 13:19 wasm-cache-workaround
Commit 369cb383159f68cebc504c126290d36d3c7610f9e956bd03fecfa568137dceb2
--- extsrc/pikchr-worker.js
+++ extsrc/pikchr-worker.js
@@ -206,11 +206,11 @@
206206
data:{step: ++f.last.step, text: text||null}
207207
});
208208
}
209209
};
210210
211
- importScripts('pikchr-v32459876.js');
211
+ importScripts('pikchr-v7583078860.js');
212212
/**
213213
initPikchrModule() is installed via pikchr.js due to
214214
building with:
215215
216216
emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initPikchrModule
217217
--- extsrc/pikchr-worker.js
+++ extsrc/pikchr-worker.js
@@ -206,11 +206,11 @@
206 data:{step: ++f.last.step, text: text||null}
207 });
208 }
209 };
210
211 importScripts('pikchr-v32459876.js');
212 /**
213 initPikchrModule() is installed via pikchr.js due to
214 building with:
215
216 emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initPikchrModule
217
--- extsrc/pikchr-worker.js
+++ extsrc/pikchr-worker.js
@@ -206,11 +206,11 @@
206 data:{step: ++f.last.step, text: text||null}
207 });
208 }
209 };
210
211 importScripts('pikchr-v7583078860.js');
212 /**
213 initPikchrModule() is installed via pikchr.js due to
214 building with:
215
216 emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initPikchrModule
217
--- extsrc/pikchr.js
+++ extsrc/pikchr.js
@@ -300,11 +300,11 @@
300300
301301
// end include: URIUtils.js
302302
// include: runtime_exceptions.js
303303
// end include: runtime_exceptions.js
304304
function findWasmBinary() {
305
- var f = "pikchr-v09854133.wasm";
305
+ var f = "pikchr-v7583078860.wasm";
306306
if (!isDataURI(f)) {
307307
return locateFile(f);
308308
}
309309
return f;
310310
}
311311
--- extsrc/pikchr.js
+++ extsrc/pikchr.js
@@ -300,11 +300,11 @@
300
301 // end include: URIUtils.js
302 // include: runtime_exceptions.js
303 // end include: runtime_exceptions.js
304 function findWasmBinary() {
305 var f = "pikchr-v09854133.wasm";
306 if (!isDataURI(f)) {
307 return locateFile(f);
308 }
309 return f;
310 }
311
--- extsrc/pikchr.js
+++ extsrc/pikchr.js
@@ -300,11 +300,11 @@
300
301 // end include: URIUtils.js
302 // include: runtime_exceptions.js
303 // end include: runtime_exceptions.js
304 function findWasmBinary() {
305 var f = "pikchr-v7583078860.wasm";
306 if (!isDataURI(f)) {
307 return locateFile(f);
308 }
309 return f;
310 }
311
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
cannot compute difference between binary files
11
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
0 annot compute difference between binary files
1
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
0 annot compute difference between binary files
1
--- src/fossil.page.pikchrshowasm.js
+++ src/fossil.page.pikchrshowasm.js
@@ -120,11 +120,16 @@
120120
}
121121
});
122122
delete PS._config;
123123
}
124124
125
- PS.worker = new Worker('builtin/extsrc/pikchr-worker.js');
125
+ /* Randomize the name of the worker script so that it is never cached.
126
+ ** The Fossil /builtin method will automatically remove the "-v000000000"
127
+ ** part of the filename, resolving it to just "pikchr-worker.js". */
128
+ PS.worker = new Worker('builtin/extsrc/pikchr-worker-v'+
129
+ (Math.floor(Math.random()*10000000000) + 1000000000)+
130
+ '.js');
126131
PS.worker.onmessage = (ev)=>PS.runMsgHandlers(ev.data);
127132
PS.addMsgHandler('stdout', console.log.bind(console));
128133
PS.addMsgHandler('stderr', console.error.bind(console));
129134
130135
/** Handles status updates from the Module object. */
131136
--- src/fossil.page.pikchrshowasm.js
+++ src/fossil.page.pikchrshowasm.js
@@ -120,11 +120,16 @@
120 }
121 });
122 delete PS._config;
123 }
124
125 PS.worker = new Worker('builtin/extsrc/pikchr-worker.js');
 
 
 
 
 
126 PS.worker.onmessage = (ev)=>PS.runMsgHandlers(ev.data);
127 PS.addMsgHandler('stdout', console.log.bind(console));
128 PS.addMsgHandler('stderr', console.error.bind(console));
129
130 /** Handles status updates from the Module object. */
131
--- src/fossil.page.pikchrshowasm.js
+++ src/fossil.page.pikchrshowasm.js
@@ -120,11 +120,16 @@
120 }
121 });
122 delete PS._config;
123 }
124
125 /* Randomize the name of the worker script so that it is never cached.
126 ** The Fossil /builtin method will automatically remove the "-v000000000"
127 ** part of the filename, resolving it to just "pikchr-worker.js". */
128 PS.worker = new Worker('builtin/extsrc/pikchr-worker-v'+
129 (Math.floor(Math.random()*10000000000) + 1000000000)+
130 '.js');
131 PS.worker.onmessage = (ev)=>PS.runMsgHandlers(ev.data);
132 PS.addMsgHandler('stdout', console.log.bind(console));
133 PS.addMsgHandler('stderr', console.error.bind(console));
134
135 /** Handles status updates from the Module object. */
136
--- src/main.mk
+++ src/main.mk
@@ -2142,10 +2142,11 @@
21422142
-sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c \
21432143
-sENVIRONMENT=web \
21442144
-sMODULARIZE \
21452145
-sEXPORT_NAME=initPikchrModule \
21462146
--minify 0
2147
+ $(TCLSH) $(TOPDIR)/tools/randomize-js-names.tcl $(SRCDIR_extsrc)
21472148
@chmod -x $(SRCDIR_extsrc)/pikchr.wasm
21482149
wasm: $(SRCDIR_extsrc)/pikchr.js
21492150
21502151
#
21512152
# compile_commands.json support...
21522153
--- src/main.mk
+++ src/main.mk
@@ -2142,10 +2142,11 @@
2142 -sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c \
2143 -sENVIRONMENT=web \
2144 -sMODULARIZE \
2145 -sEXPORT_NAME=initPikchrModule \
2146 --minify 0
 
2147 @chmod -x $(SRCDIR_extsrc)/pikchr.wasm
2148 wasm: $(SRCDIR_extsrc)/pikchr.js
2149
2150 #
2151 # compile_commands.json support...
2152
--- src/main.mk
+++ src/main.mk
@@ -2142,10 +2142,11 @@
2142 -sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c \
2143 -sENVIRONMENT=web \
2144 -sMODULARIZE \
2145 -sEXPORT_NAME=initPikchrModule \
2146 --minify 0
2147 $(TCLSH) $(TOPDIR)/tools/randomize-js-names.tcl $(SRCDIR_extsrc)
2148 @chmod -x $(SRCDIR_extsrc)/pikchr.wasm
2149 wasm: $(SRCDIR_extsrc)/pikchr.js
2150
2151 #
2152 # compile_commands.json support...
2153
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -575,10 +575,11 @@
575575
-sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c <<<NEXT_LINE>>>
576576
-sENVIRONMENT=web <<<NEXT_LINE>>>
577577
-sMODULARIZE <<<NEXT_LINE>>>
578578
-sEXPORT_NAME=initPikchrModule <<<NEXT_LINE>>>
579579
--minify 0
580
+ $(TCLSH) $(TOPDIR)/tools/randomize-js-names.tcl $(SRCDIR_extsrc)
580581
@chmod -x $(SRCDIR_extsrc)/pikchr.wasm
581582
wasm: $(SRCDIR_extsrc)/pikchr.js
582583
583584
#
584585
# compile_commands.json support...
585586
586587
ADDED tools/randomize-js-names.tcl
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -575,10 +575,11 @@
575 -sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c <<<NEXT_LINE>>>
576 -sENVIRONMENT=web <<<NEXT_LINE>>>
577 -sMODULARIZE <<<NEXT_LINE>>>
578 -sEXPORT_NAME=initPikchrModule <<<NEXT_LINE>>>
579 --minify 0
 
580 @chmod -x $(SRCDIR_extsrc)/pikchr.wasm
581 wasm: $(SRCDIR_extsrc)/pikchr.js
582
583 #
584 # compile_commands.json support...
585
586 DDED tools/randomize-js-names.tcl
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -575,10 +575,11 @@
575 -sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c <<<NEXT_LINE>>>
576 -sENVIRONMENT=web <<<NEXT_LINE>>>
577 -sMODULARIZE <<<NEXT_LINE>>>
578 -sEXPORT_NAME=initPikchrModule <<<NEXT_LINE>>>
579 --minify 0
580 $(TCLSH) $(TOPDIR)/tools/randomize-js-names.tcl $(SRCDIR_extsrc)
581 @chmod -x $(SRCDIR_extsrc)/pikchr.wasm
582 wasm: $(SRCDIR_extsrc)/pikchr.js
583
584 #
585 # compile_commands.json support...
586
587 DDED tools/randomize-js-names.tcl
--- a/tools/randomize-js-names.tcl
+++ b/tools/randomize-js-names.tcl
@@ -0,0 +1,36 @@
1
+#!/usr/bin/tclsh
2
+#
3
+# This script is run as part of "make wasm". After emcc has
4
+# run to generate extsrc/pikchr.wasm and extsrc/pikchr.js from
5
+# extsrc/pikchr.c, we need to make changes to these filenames to
6
+# work around caching problems.
7
+#
8
+# (1) in extsrc/pikchr.js -> change "pikchr.wasm" into
9
+# "pikchr-vNNNNNNNN.wasm" where Ns are random digits.
10
+#
11
+# (2) in extsrc/pikchr-worker.js -> change "pikchr-vNNNNNNNN.js"
12
+# by altering the random digits N.
13
+#
14
+set DIR extsrc
15
+if {[llength $argv]>0} {
16
+ set DIR [lindex $argv 0]
17
+}
18
+
19
+set R [expr {int(rand()*10000000000)+1000000000}]
20
+set in [open $DIR/pikchr.js rb]
21
+set f1 [read $in]
22
+close $in
23
+set f1mod [regsub {\ypikchr(-v\d+)?\.wasm\y} $f1 "pikchr-v$R.wasm"]
24
+set out [open $DIR/pikchr.js wb]
25
+puts -nonewline $out $f1mod
26
+close $out
27
+puts "modified $DIR/pikchr.js to reference \"pikchr-v$R.wasm\""
28
+
29
+set in [open $DIR/pikchr-worker.js rb]
30
+set f1 [read $in]
31
+close $in
32
+set f1mod [regsub {\ypikchr(-v\d+)?\.js\y} $f1 "pikchr-v$R.js"]
33
+set out [open $DIR/pikchr-worker.js wb]
34
+puts -nonewline $out $f1mod
35
+close $out
36
+puts "modified $DIR/pikchr-worker.js to reference \"pikchr-v$R.js\""
--- a/tools/randomize-js-names.tcl
+++ b/tools/randomize-js-names.tcl
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/tools/randomize-js-names.tcl
+++ b/tools/randomize-js-names.tcl
@@ -0,0 +1,36 @@
1 #!/usr/bin/tclsh
2 #
3 # This script is run as part of "make wasm". After emcc has
4 # run to generate extsrc/pikchr.wasm and extsrc/pikchr.js from
5 # extsrc/pikchr.c, we need to make changes to these filenames to
6 # work around caching problems.
7 #
8 # (1) in extsrc/pikchr.js -> change "pikchr.wasm" into
9 # "pikchr-vNNNNNNNN.wasm" where Ns are random digits.
10 #
11 # (2) in extsrc/pikchr-worker.js -> change "pikchr-vNNNNNNNN.js"
12 # by altering the random digits N.
13 #
14 set DIR extsrc
15 if {[llength $argv]>0} {
16 set DIR [lindex $argv 0]
17 }
18
19 set R [expr {int(rand()*10000000000)+1000000000}]
20 set in [open $DIR/pikchr.js rb]
21 set f1 [read $in]
22 close $in
23 set f1mod [regsub {\ypikchr(-v\d+)?\.wasm\y} $f1 "pikchr-v$R.wasm"]
24 set out [open $DIR/pikchr.js wb]
25 puts -nonewline $out $f1mod
26 close $out
27 puts "modified $DIR/pikchr.js to reference \"pikchr-v$R.wasm\""
28
29 set in [open $DIR/pikchr-worker.js rb]
30 set f1 [read $in]
31 close $in
32 set f1mod [regsub {\ypikchr(-v\d+)?\.js\y} $f1 "pikchr-v$R.js"]
33 set out [open $DIR/pikchr-worker.js wb]
34 puts -nonewline $out $f1mod
35 close $out
36 puts "modified $DIR/pikchr-worker.js to reference \"pikchr-v$R.js\""

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button