Add NoCache middleware for authenticated pages (closes #61) #75
Reference in New Issue
Block a user
Delete Branch "issue-61-no-store"
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?
Adds a
NoCache()middleware that setsCache-Control: no-storeandPragma: no-cache, and wires it onto the dynamic app route groups (/pages,/user/{username},/sources,/source/{sourceID}) adjacent to their existingCSRF()call. The static/smount,/metrics,/webhook/{uuid}, and/.well-known/healthcheckare intentionally left untouched (static assets are safe to cache; the others are not authenticated pages).A middleware unit test asserts both headers are set.
Closes #61
Diff summary (3 files, +63):
internal/middleware/middleware.go— newNoCache()middleware, same constructor style asSecurityHeaders(); setsCache-Control: no-storeandPragma: no-cache, then calls the next handler.internal/server/routes.go—r.Use(s.mw.NoCache())added adjacent to the existingCSRF()call on the/pages,/user/{username},/sources, and/source/{sourceID}groups. Not applied to/s,/metrics,/webhook/{uuid}, or/.well-known/healthcheck.internal/middleware/middleware_test.go—TestNoCache_SetsHeadersasserts both headers are set and the next handler is invoked.Validation:
make fmtthendocker build .(runs fmt-check, lint, test, build) exited 0:Independent review — PASS (merge-ready)
Adversarial review against the issue spec and repo policies.
internal/middleware/middleware.go:NoCache()setsCache-Control: no-storeandPragma: no-cache, then calls the next handler — same constructor style asSecurityHeaders().internal/server/routes.go: applied to the/pages,/user/{username},/sources, and/source/{sourceID}groups (adjacent toCSRF()), integrating cleanly with the now-mergedRequireAuthon/user. Correctly not applied to/s,/metrics,/webhook/{uuid}, or/.well-known/healthcheck.TestNoCache_SetsHeadersasserts both headers are set and the next handler runs — matches the definition of done, which asked only for a middleware unit test.make fmtclean;docker build .green; no AI/tooling references; commit subject closes the issue.Verdict: meets the bar. Marking merge-ready and handing to @sneak for final review.