Skip to content

Serve mode caches stale pages — send Cache-Control: no-store #8

Open

Description

@mickdarling

Found during a live editing session against the mickdarling.com Hugo site.

Symptom: edit content → rebuild the diff output → refresh the viewer → the old content still shows. Looks like the rebuild failed; it didn't.

Cause: serve mode uses plain python3 -m http.server, which sends no Cache-Control header. Browsers then apply heuristic caching (based on Last-Modified) to the iframe pages, so a normal refresh of viewer.html re-uses cached copies of the old/new panes. A hard refresh works but nobody thinks of that mid-edit-loop — the tool just looks broken.

Fix: subclass SimpleHTTPRequestHandler and send Cache-Control: no-store, must-revalidate in end_headers(). ~10 lines, no dependencies. Belt-and-suspenders option: also append a cache-busting query (build timestamp) to iframe URLs in viewer.html.

Happy to PR this — workaround verified locally with a no-store wrapper server.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BhExuJig6F4CCbz7q3Z39a

Activity

  1. mickdarling commented on Jul 26, 2026

    @mickdarling
    MemberAuthor

    Field update that changes the recommendation: hard refresh (⌘⇧R) was not sufficient — Chrome still served the cached iframe panes even with the top document force-reloaded, and even after the server was swapped to send Cache-Control: no-store (already-cached entries don't revalidate against a header they were stored without).

    So cache-busting the iframe URLs should be the primary fix, not the optional one. Verified working locally with a one-line change in viewer.html's updateRoute(): append a build stamp to the pane URLs —

    const oldSrc = `./old${currentRoute}?v=${BUILD_STAMP}`;
    const newSrc = `./new${currentRoute}?v=${BUILD_STAMP}`;

    with BUILD_STAMP injected at generation time by build-rendered-diff-viewer.sh. Every rebuild then forces genuinely fresh panes on a plain refresh. The no-store server header is still worth adding for the assets the stamp doesn't reach, but the stamp is what actually ends the stale-content illusion.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01BhExuJig6F4CCbz7q3Z39a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions