Preview iframe serves a stale page from the browser cache after returning to the View module (pass --noHTTPCache to hugo) #342
Labels
No labels
bug
enhancement
needs-triage
ready-for-agent
ready-for-human
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/deckle#342
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The preview iframe shows a stale page after the user leaves the View module, saves an element and comes back: the recreated iframe is served from the browser's HTTP cache because
hugo serveranswers pages withLast-Modifiedand noCache-Control. Launching Hugo with--noHTTPCachemakes it sendCache-Control: no-store, no-cache, must-revalidate, max-age=0, so a recreated iframe always revalidates.Current behavior
Reported on the hosted editor (site
cloonar): "the preview is not reloading when I change things; I have to right-click → This frame → Reload." LiveReload itself is fine: in a standalone tab the/livereloadsocket stays open and the page reloads on save. The failing flow is inside the editor:/<lang>/<page>/).Reproduced in headless Chromium (CDP) against a local
harness serveon the scaffold site: after step 4 the iframe document arrives withfromDiskCache: trueand does not contain the saved text, while a direct fetch of the same URL from Hugo already does. Hugo's response headers for a page areContent-Type,Content-Length,Last-Modified,Date,Accept-Ranges— noCache-Control— so the browser applies heuristic freshness (about 10% of the page's age) and reuses the cached document without revalidating. The hosted control plane and Caddy pass Hugo's headers through unchanged, so the same happens there. Hugo 0.167'sservercommand only sends the no-cache headers when started with--noHTTPCache(its default is off).Desired behavior
Every page the preview serves is revalidated on each load: a recreated iframe (step 4) shows the saved content without a manual frame reload. LiveReload keeps working as today for an iframe that stays mounted.
Decisions
PreviewPane.--noHTTPCacheunconditionally (loopback and--preview-base-urlalike) — the cache problem is the browser's, not the proxy's.Key interfaces
hugo serverininternal/supervisor(Supervisor.runOnce) — add--noHTTPCache.internal/supervisor/supervisor_test.goasserts the argument list for both launch modes; extend it.docs/harness.md"Serving" names the flagsharness servepasses to Hugo (--buildDrafts, the bind, and under "Serving the preview behind a reverse proxy"--appendPort=false/--liveReloadPort); name the new one there. The README gains nothing. No scaffolded skill walks through Hugo's flags (preview-siteonly runsharness serve), so none changes.Acceptance criteria
hugo serverlaunched byharness serveis passed--noHTTPCache, in loopback mode and with--preview-base-url.Cache-Control: no-store, no-cache, must-revalidate, max-age=0(andPragma: no-cache).docs/harness.md"Serving" lists the flag; the README's line budget and link tests still pass.How to verify
go test ./internal/supervisor/ ./docs/ ./cmd/harness/.harness inita scratch site,harness serve --site <dir>, thencurl -sI http://127.0.0.1:<preview-port>/shows theCache-Controlheader.Assumptions to check
--noHTTPCacheapplies to every served page including the in-memory render (it is set in the file server handler,commands/server.go); confirm with the curl above rather than from this brief.Out of scope
PreviewPanere-points or reloads the iframe (issue #241's discipline stays).Blocked by
None - can start immediately