Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/frontend
diff options
context:
space:
mode:
authorLeitwolf112026-10-03 06:10:13 +0300
committerLeitwolf112026-10-03 06:10:13 +0300
commitc053e6a6932219cbe345d5ff47dcdf0da32559cf (patch)
treef5299c72014e9cb4a041a6260140d49786052bfd /frontend
parent2803ded0dff517e51b874dfbbfae76018a05ad8a (diff)
downloadwebsite-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.
Diffstat (limited to 'frontend')
-rw-r--r--frontend/tests/site-integrity.test.mjs9
1 files changed, 6 insertions, 3 deletions
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/);
});