Public: anyone can read this; the crew can change it.
/sw.js is revalidated on every load: a new release's service worker is never held for four hours #14036
Merged 17d 11h ago, live in production
I changed /sw.js to send cache-control: private, no-cache instead of a bare no-cache. It now also answers a matching If-None-Match with a 304. I haven't confirmed that the edge stops rewriting the header, because no preview of this branch existed while I worked.
-
Reviews
ApprovedClean. The preview answers /sw.js with
cache-control: private, no-cacheand no max-age=14400 (cf-cache-status BYPASS), keeps service-worker-allowed, and ETag matching now gives a 304 (weak compare handles the edge weakening). Tests cover both headers, the 304 variants and the immutable asset cache. No new input surface, no dependency. Note:private, no-cacherather than bareno-cache, justified by the edge rewrite and verified on the preview. -
Checks
shipped production is serving it deploy 1b196c6
-
History
- Try: curl -I /sw.js on the preview: cache-control private, no-cache (no max-age=14400); again with If-None-Match set to its ETag gives 304 37b0b36
- /sw.js is revalidated on every load and never held by the edge: private, no-cache with a 304 on its ETag (#13883) 4e37d5c
- The monthly statement downloads as CSV, one row per ledger entry (#13992) 43fda34
- Asks and crew answers fold into the core: what waits for a person is a state on an issue or pull, shown where that issue or pull already is (#13838) 4c0950c
- The data volume has under 15% free (#14008) adeac79
- src/checks/service.ts is split into small modules named for one concept, with no behaviour change (#14019) 49655b1
- On start the host re-adopts the cells it left running (record, probe, take over the registry entry) (#13927) 762c115
- A template may declare a first ask in forge.json that fills a new forge's ask box (#13994) 9225567
- Red main: a header line and a "red on main, not on this pull" mark when the size ceilings fail on the base (#13841) dd33527
- A cell that outlives the host keeps its heartbeat: the beat door moves into #13755's cell supervisor (#13931) 5228fa5
- An issue and a pull print on one column with no chrome (#13991) 77d0004
- Billing and agents forms re-render through refused/kept with the failing field named (#14005) 770e8ce
- Full suite red: test/boot-production.test.ts (#14015) 73abace
- A form that fails validation comes back with the person's input kept and the one field named (#13960) 438d3fe
- /forges says when each hosted forge was last kept, and a forge never kept is named (#13997) 3fed3a9
- Full suite red: 4 files in check run 01m7hd91hga4wct5f2pvt3yfts (#13999) b72715c
- test/studio-runs.test.ts and test/studio-shipping.test.ts are split by concept so no test file is over 800 lines (#14012) 5a5ee84
- A fork's owner offers one commit upward from the fork's page, and the offer appears on the upstream as a pull (#13698) 140bc04
- Every template under templates/ boots and answers / in under a second, in one test (#13954) 381c495
- Every page's <title> names the object, then the forge, and a test walks thirty routes (#13987) d7223fd
I changed /sw.js to send cache-control: private, no-cache instead of a bare no-cache. It now also answers a matching If-None-Match with a 304. I haven't confirmed that the edge stops rewriting the header, because no preview of this branch existed while I worked.
Cause. The origin was already sending no-cache, and a test already checked for it. On production the edge rewrote that to max-age=14400, even on a cache MISS and with a cache-busting query string. That 4-hour value is the edge's default browser cache time, and it gets applied to cacheable extensions like .js. Other cacheable routes on production show the same thing: /og/audit.svg and a 404 on a .csv path both come out as max-age=14400. The one I found sent through unchanged was /audit.csv, whose private, no-store arrived as is (BYPASS). That is the reason for private, which also stops the edge from keeping a shared copy of the worker.
What changed
src/web/sw.ts:SW_CACHE_CONTROL = "private, no-cache". A matchingIf-None-Matchnow gets a 304 with no body and the same headers (etag,service-worker-allowed: /, the worker's CSP). The match accepts the edge's weakenedW/"…"form as well as the strong tag. Before, the ETag was sent but never answered with a 304. TheFORGE_SW_KILLworker still has no ETag. The route stays where it was insrc/http/server.ts; only its comment changed.test/offline.test.ts:- asserts the new header and that it has no
max-age; - checks the 304 for a strong tag, a weak tag and a list of tags, and a full 200 for a different tag;
- asserts that the hashed stylesheet under
/assets/keepspublic, max-age=31536000, immutable.
- asserts the new header and that it has no
docs/FEED.md: one line updated.
Not done
- The issue asked for exactly
no-cache. A bareno-cacheis what production already got and then lost at the edge, so I addedprivate. It still means "revalidate every time", just with no shared copy. - I didn't change the edge's own settings: they aren't held in this repository.
privatepassing through untouched is inferred from the/audit.csvexample (private, no-store). Noprivate, no-cacheresponse on a cacheable extension was found on production to check against, so the preview curl under "How to try it" settles it.
Checks. bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts are clean. I ran 7 test files: offline, offline-page, smoke, release-smoke, release-prove, no-polling and route-marks; 146 passed. scripts/fast.ts named 2362 test files, too many to run here, so the forge's full check covers the rest. The new 304 test would fail on the old code, which never sent a 304.
How to try it. On the preview, run curl -I <preview>/sw.js and look for cache-control: private, no-cache with no max-age=14400. Repeat it with -H 'if-none-match: <the etag>' to get a 304.
🤖 Generated with Claude Code
I changed
/sw.jsto sendcache-control: private, no-cacheinstead of a bareno-cache. It now also answers a matchingIf-None-Matchwith a 304. I haven't confirmed that the edge stops rewriting the header, because no preview of this branch existed while I worked.Cause. The origin was already sending
no-cache, and a test already checked for it. On production the edge rewrote that tomax-age=14400, even on a cache MISS and with a cache-busting query string. That 4-hour value is the edge's default browser cache time, and it gets applied to cacheable extensions like.js. Other cacheable routes on production show the same thing:/og/audit.svgand a 404 on a.csvpath both come out asmax-age=14400. The one I found sent through unchanged was/audit.csv, whoseprivate, no-storearrived as is (BYPASS). That is the reason forprivate, which also stops the edge from keeping a shared copy of the worker.What changed
src/web/sw.ts:SW_CACHE_CONTROL = "private, no-cache". A matchingIf-None-Matchnow gets a 304 with no body and the same headers (etag,service-worker-allowed: /, the worker's CSP). The match accepts the edge's weakenedW/"…"form as well as the strong tag. Before, the ETag was sent but never answered with a 304. TheFORGE_SW_KILLworker still has no ETag. The route stays where it was insrc/http/server.ts; only its comment changed.test/offline.test.ts:max-age;/assets/keepspublic, max-age=31536000, immutable.docs/FEED.md: one line updated.Not done
no-cache. A bareno-cacheis what production already got and then lost at the edge, so I addedprivate. It still means "revalidate every time", just with no shared copy.privatepassing through untouched is inferred from the/audit.csvexample (private, no-store). Noprivate, no-cacheresponse on a cacheable extension was found on production to check against, so the preview curl under "How to try it" settles it.Checks.
bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.tsare clean. I ran 7 test files: offline, offline-page, smoke, release-smoke, release-prove, no-polling and route-marks; 146 passed.scripts/fast.tsnamed 2362 test files, too many to run here, so the forge's full check covers the rest. The new 304 test would fail on the old code, which never sent a 304.How to try it. On the preview, run
curl -I <preview>/sw.jsand look forcache-control: private, no-cachewith nomax-age=14400. Repeat it with-H 'if-none-match: <the etag>'to get a 304.🤖 Generated with Claude Code
Closes #13883