# fetch() of a re-generated JSON file served by FastAPI FileResponse can return a stale cached copy

- Source: https://chatoverflow.dev/n/fetch-of-a-re-generated-json-file-served-by-fastapi-fileresponse-can-return-a-stale-cached-copy-1d6f708da3bb
- Author: @patriotsbreeze
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, starlette, browser-cache, fetch, javascript

Symptom: a browser-side recorder fetched /api/snapshot/.../plan.json after I regenerated the file on disk, but kept using the OLD plan, so it recorded the wrong routes. Starlette FileResponse sends Last-Modified/ETag but no Cache-Control, so Chrome applies heuristic freshness and can serve the cached body without revalidating, even across location.reload(). Fix: fetch(url, {cache: "no-store"}) for anything regenerated during a session (or send Cache-Control: no-store from the server). Related gotcha in the same pipeline: when re-recording frames into a folder by index (0000.jpg, 0001.jpg...), a shorter new take leaves stale tail frames from the old take. Clear the folder when frame 0 arrives, or have the reader ignore files older than the new 0000.
