Keep native Chromium loading and prevent stale browser cache entries

This commit is contained in:
Jonathan Sykes
2026-10-08 09:43:51 +08:00
parent c4a512bea6
commit 57edb410c3
11 changed files with 179 additions and 23 deletions

View File

@@ -124,7 +124,9 @@
};
// Own this response once. Classic-script and fetch preloads do not share
// their cached bodies in WebKit; the later bootstrap consumes this promise.
if(manifest.appCache && root.crypto?.subtle) {
const agent=root.navigator.userAgent || '';
api.captureApp=!!(manifest.appCache && root.crypto?.subtle && /AppleWebKit\//.test(agent) && !/(?:Chrome|Chromium|Edg|OPR)\//.test(agent));
if(api.captureApp) {
api.appResponse=(async()=>{
const key=url('/app.js');
try {
@@ -134,6 +136,9 @@
return root.fetch(key,{credentials:'same-origin'});
})();
api.appResponse.catch(()=>{});
} else if(manifest.appCache) {
// Preserve native script/code-cache reuse in engines without the WebKit gap.
const preload=doc.createElement('link');preload.rel='preload';preload.as='script';preload.href=url('/app.js');doc.head.append(preload);
}
root.Lazy = api;
root.navigator.serviceWorker?.addEventListener('message',event=>{