diff options
| author | Leitwolf11 | 2026-10-03 06:10:13 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-10-03 06:10:13 +0300 |
| commit | c053e6a6932219cbe345d5ff47dcdf0da32559cf (patch) | |
| tree | f5299c72014e9cb4a041a6260140d49786052bfd | |
| parent | 2803ded0dff517e51b874dfbbfae76018a05ad8a (diff) | |
| download | website-fix/forum-asset-cache-key.tar.gz | |
Give the forum assets a cache keyfix/forum-asset-cache-key
The edge cache can keep an error response for a static asset for hours. It
did so for the forum script while the files were being replaced. The forum
page now requests its stylesheet and script with a version query; Nginx
serves the same file path, and a new value gives the edge a fresh key.
The integrity test accepts the versioned references.
| -rw-r--r-- | forum/index.html | 4 | ||||
| -rw-r--r-- | frontend/tests/site-integrity.test.mjs | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/forum/index.html b/forum/index.html index 3758b28..2f1e648 100644 --- a/forum/index.html +++ b/forum/index.html @@ -8,9 +8,9 @@ <meta name="robots" content="noindex, nofollow" /> <meta name="theme-color" content="#11101a" /> <link rel="icon" type="image/svg+xml" href="/visual-xsharp-mark.svg" /> - <link rel="stylesheet" href="/site.css" /> + <link rel="stylesheet" href="/site.css?v=2026-10-03" /> <title>The forum isn't open yet. · Visual X#</title> - <script src="/site.js" defer></script> + <script src="/site.js?v=2026-10-03" defer></script> </head> <body> <header> diff --git a/frontend/tests/site-integrity.test.mjs b/frontend/tests/site-integrity.test.mjs index 6da461d..114b0cc 100644 --- a/frontend/tests/site-integrity.test.mjs +++ b/frontend/tests/site-integrity.test.mjs @@ -34,12 +34,15 @@ test("the forum placeholder is explicitly non-indexable and not an account servi assert.match(nginx, /X-Robots-Tag "noindex, nofollow"/); assert.match(nginx, /script-src 'self'; style-src 'self'/); assert.doesNotMatch(nginx, /unsafe-inline/); - assert.match(forum, /src="\/site\.js"/); - assert.match(forum, /href="\/site\.css"/); + assert.match(forum, /src="\/site\.js[?"]/); + assert.match(forum, /href="\/site\.css[?"]/); const normalizedForum = forum.toLowerCase(); assert.equal(normalizedForum.split("<script").length - 1, 1); assert.equal(normalizedForum.split("</script>").length - 1, 1); - assert.ok(normalizedForum.includes('<script src="/site.js" defer></script>')); + // The query string is a cache key for the edge cache. Nginx serves the + // exact file path, so changing the value forces a fresh copy after a deploy. + assert.match(normalizedForum, /<script src="\/site\.js\?v=[0-9-]+" defer><\/script>/); + assert.match(normalizedForum, /<link rel="stylesheet" href="\/site\.css\?v=[0-9-]+" \/>/); assert.doesNotMatch(forum, /<form\b/); }); |