fix(seo): set Cache-Control no-cache on /robots.txt - #97
Merged
Merged
Conversation
- Change /robots.txt cache header from max-age=86400 to no-cache in handlers and middleware - Prevent CDN edge caching delays so crawler directives revalidate with origin in real-time - Update TestCacheControlHeaders expectation in handlers_test.go
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.
Bug Description & Symptom
/robots.txthadCache-Control: public, max-age=86400, causing Cloudflare edge CDN and intermediate proxies to cache crawling rules for 24 hours. When robots directives were updated, crawlers continued to receive stale cached directives.Root Cause Analysis
The origin server explicitly sent
Cache-Control: public, max-age=86400from bothhandleRobotsTXTand thecacheControlmiddleware. This instructed downstream CDNs (Cloudflare) to store the response in edge caches without revalidating with origin on every request.Proposed Fix
Cache-Controlheader on/robots.txtfrompublic, max-age=86400tono-cacheinhandleRobotsTXT(handlers.go) and thecacheControlmiddleware (compress.go).TestCacheControlHeaders(handlers_test.go).Scope Lock & Blast Radius
/robots.txtcaching header.Mandatory Zero-Failure Pre-Commit Verification (AGENTS.md)
All commands below must be executed locally and pass with Exit Code 0 prior to creating the PR:
Backend Suite (if backend code changed)
gofmt -w . && gofmt -l .(Output must be completely empty)go vet ./...(Static analysis clean)go test -count=1 -v ./...(All tests pass with cache disabled)Frontend Suite (if frontend code changed)
npm run format && npm run lint(Prettier code style & ESLint clean)npm run check(SvelteKit TypeScript validation clean)npm run build(Production build succeeds with static adapter)Live Localhost End-to-End (E2E) Verification (Mandatory)
go run ./cmd/server/ preview) with 0 startup crashes/panics.Local Verification Evidence