Cache-Control opt-in default + CLAUDE.md production-hardening checklist#31
Merged
Conversation
The middleware previously set `public, max-age=3600` on every 200 GET, which would cache authenticated, per-user, or mutable responses (e.g. the notes example resource) at shared/CDN caches and in the browser — a read-after-write staleness and potential cross-user exposure foot-gun. Default every response to `no-store` instead; an endpoint that serves genuinely public, cacheable data opts in by setting its own Cache-Control, which the middleware leaves intact.
Agent-facing orientation, the template's conventions (cache opt-in, proxy-aware rate limiting, SQLite-tests vs Postgres-prod, structured logging), and a provider-agnostic "production hardening" checklist distilled from running a sibling service through a high-traffic live event: validate migrations against real Postgres, expand→transition→contract schema changes, non-blocking startup readiness, log exception types, keep static-reference reads off hot paths, and more.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Transfers two general-case lessons from a sibling service's live-event launch into the template.
Changes
fix: default
Cache-Controltono-store; caching is opt-inThe cache middleware set
public, max-age=3600on every 200 GET — including authenticated, per-user, or mutable responses like thenotesexample resource. That caches private data at shared/CDN caches and in the browser (a read-after-write staleness and potential cross-user exposure foot-gun). Every response now defaults tono-store; an endpoint that serves genuinely public, cacheable data opts in by setting its ownCache-Control, which the middleware leaves intact.Behavior change: GET responses are no longer cached unless they explicitly opt in.
docs: add
CLAUDE.mdAgent-facing orientation, the template's conventions, and a provider-agnostic production hardening checklist distilled from running a sibling service through a high-traffic live event: validate migrations against real Postgres (tests use SQLite + never run Alembic), expand→transition→contract schema changes, non-blocking startup readiness, log exception types, keep static-reference reads off hot paths,
merge ≠ deploy, and more.Test plan
uv run ruff check .— passuv run ruff format --check .— passuv run pytest— 32 passed