Link the app's code with a build number so a proxy cache cannot serve an old copy
build-container / build (push) Successful in 2m55s
build-container / build (push) Successful in 2m55s
The People screens did not appear after the redeploy even after a hard refresh: a caching layer (for example Nginx Proxy Manager's "Cache Assets") was still serving the old app.js. The pages now reference /app.js?v=<build>, /style.css?v=<build> etc., where the build changes with every release, so a stale cached file at the old address is never used. The service worker no longer precaches unversioned app code. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
12a1e50a0e
commit
1a29d500d3
3 files changed
+10
-3
No files matched your search
@@ -56,6 +56,10 @@ const wait = ms => new Promise(r => setTimeout(r, ms));
|
||||
ok('and an unchanged file is answered with a cheap 304', a2.status === 304, a2.status);
|
||||
const i1 = await fetch(base + '/icons/icon-192.png'); await i1.arrayBuffer(); ok('icons are cached for a week', /max-age=604800/.test(i1.headers.get('cache-control') || ''), i1.headers.get('cache-control'));
|
||||
const cfg = await (await fetch(base + '/api/config', { headers: { cookie } })).json(); ok('the server reports a build stamp so open pages can tell a newer version exists', /^[0-9a-f]{12}$/.test(cfg.build || ''), cfg.build);
|
||||
const home = await (await fetch(base + '/', { headers: { cookie } })).text(), cfg2 = await (await fetch(base + '/api/config', { headers: { cookie } })).json();
|
||||
ok('the app page links its code with the current build number, so a cached old copy can never be used', home.includes(`/app.js?v=${cfg2.build}`) && home.includes(`/style.css?v=${cfg2.build}`), home.match(/app\.js[^"]*/));
|
||||
const login = await (await fetch(base + '/login')).text(); ok('so does the sign-in page', login.includes(`/login.js?v=${cfg2.build}`), login.match(/login\.js[^"]*/));
|
||||
const va = await fetch(base + `/app.js?v=${cfg2.build}`, { headers: { cookie } }); ok('the versioned address serves the file', va.status === 200 && (await va.text()).includes('addPersonSheet'), va.status);
|
||||
ok('the server is still running after all of that', alive);
|
||||
child.kill(); fs.rmSync(dir, { recursive: true, force: true });
|
||||
if (failed) { console.log('\n--- server log ---\n' + log.split('\n').filter(l => /error|Error|not defined/.test(l)).slice(0, 12).join('\n')); }
|
||||
|
||||
Reference in new issue
Block a user