Fossil SCM

Adjust the /builtin page such that if a filename contains "-v12345689" as part of its name right before a ".", where the digits can vary, then that part of the name is ignored. We can thus give semi-random names to built-in resources (ex: extsrc/pikchr-v12345678.wasm) to defeat aggressive browser caches. This is experimental.

drh 2025-03-04 18:42 UTC trunk
Commit a9f4bbb09fa148cc7096e1eaa65917db90ba5573236a94fe7be31c5bc7ae7ba5
1 file changed +15
--- src/builtin.c
+++ src/builtin.c
@@ -52,17 +52,32 @@
5252
return -1;
5353
}
5454
5555
/*
5656
** Return a pointer to built-in content
57
+**
58
+** If the filename contains "-vNNNNNNNN" just before the final file
59
+** suffix, where each N is a random digit, then omit that part of the
60
+** filename before doing the lookup. The extra -vNNNNNNNN was added
61
+** to defeat overly aggressive caching by web browsers.
5762
*/
5863
const unsigned char *builtin_file(const char *zFilename, int *piSize){
5964
int i = builtin_file_index(zFilename);
6065
if( i>=0 ){
6166
if( piSize ) *piSize = aBuiltinFiles[i].nByte;
6267
return aBuiltinFiles[i].pData;
6368
}else{
69
+ char *zV = strstr(zFilename, "-v");
70
+ if( zV!=0 ){
71
+ for(i=0; i<8 && fossil_isdigit(zV[i+2]); i++){}
72
+ if( i==8 && zV[10]=='.' ){
73
+ char *zNew = mprintf("%.*s%s", (int)(zV-zFilename), zFilename, zV+10);
74
+ const unsigned char *pRes = builtin_file(zNew, piSize);
75
+ fossil_free(zNew);
76
+ return pRes;
77
+ }
78
+ }
6479
if( piSize ) *piSize = 0;
6580
return 0;
6681
}
6782
}
6883
const char *builtin_text(const char *zFilename){
6984
--- src/builtin.c
+++ src/builtin.c
@@ -52,17 +52,32 @@
52 return -1;
53 }
54
55 /*
56 ** Return a pointer to built-in content
 
 
 
 
 
57 */
58 const unsigned char *builtin_file(const char *zFilename, int *piSize){
59 int i = builtin_file_index(zFilename);
60 if( i>=0 ){
61 if( piSize ) *piSize = aBuiltinFiles[i].nByte;
62 return aBuiltinFiles[i].pData;
63 }else{
 
 
 
 
 
 
 
 
 
 
64 if( piSize ) *piSize = 0;
65 return 0;
66 }
67 }
68 const char *builtin_text(const char *zFilename){
69
--- src/builtin.c
+++ src/builtin.c
@@ -52,17 +52,32 @@
52 return -1;
53 }
54
55 /*
56 ** Return a pointer to built-in content
57 **
58 ** If the filename contains "-vNNNNNNNN" just before the final file
59 ** suffix, where each N is a random digit, then omit that part of the
60 ** filename before doing the lookup. The extra -vNNNNNNNN was added
61 ** to defeat overly aggressive caching by web browsers.
62 */
63 const unsigned char *builtin_file(const char *zFilename, int *piSize){
64 int i = builtin_file_index(zFilename);
65 if( i>=0 ){
66 if( piSize ) *piSize = aBuiltinFiles[i].nByte;
67 return aBuiltinFiles[i].pData;
68 }else{
69 char *zV = strstr(zFilename, "-v");
70 if( zV!=0 ){
71 for(i=0; i<8 && fossil_isdigit(zV[i+2]); i++){}
72 if( i==8 && zV[10]=='.' ){
73 char *zNew = mprintf("%.*s%s", (int)(zV-zFilename), zFilename, zV+10);
74 const unsigned char *pRes = builtin_file(zNew, piSize);
75 fossil_free(zNew);
76 return pRes;
77 }
78 }
79 if( piSize ) *piSize = 0;
80 return 0;
81 }
82 }
83 const char *builtin_text(const char *zFilename){
84

Keyboard Shortcuts

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