CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
no-cache.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| f5b9ef5 | 1 | import type { MiddlewareHandler } from "hono"; |
| 2 | ||
| 3 | // Applied to HTML routes that must never be served stale. | |
| 4 | // CSS/JS/git pack files are NOT affected by this middleware. | |
| 5 | export const noCache: MiddlewareHandler = async (c, next) => { | |
| 6 | await next(); | |
| 7 | const ct = c.res.headers.get("Content-Type") || ""; | |
| 8 | // Only add no-cache to HTML responses — don't break asset caching | |
| 9 | if (ct.includes("text/html")) { | |
| 10 | c.res.headers.set("Cache-Control", "no-store, no-cache, must-revalidate"); | |
| 11 | c.res.headers.set("Pragma", "no-cache"); | |
| 12 | c.res.headers.set("Vary", "Cookie"); | |
| 13 | } | |
| 14 | }; |