Repository navigation
fix(cache): prevent CDN from rewriting the home browser TTL - #18
Merged
Merged
Conversation
Production Cloudflare was caching the home HTML through the CDN and rewriting Cache-Control max-age=0 to the zone's 4-hour Browser Cache TTL. - Store the five-minute edge copy in the Cache API with a public max-age header, but return a private, no-store response to clients on both cache misses and hits - Keep the Cache API as the edge cache (5 minutes); no CDN caching means the zone Browser Cache TTL can no longer rewrite the client header - The service worker still stores the no-store shell in Cache Storage for offline reuse - Update README/ARCHITECTURE/DEPLOYMENT/RUNBOOK Verified: client header is private, no-store on miss and hit; a D1 probe confirmed warm Cache API hits still omit newly inserted rows; the service worker still caches '/' for offline; typecheck, 87 tests, audit, and wrangler dry-run pass. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
🔎 Cloudflare preview: https://61477c07-feedreader.phatpham9.workers.dev Uploaded from |
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.
Problem
Production was returning the home HTML with
Cache-Control: max-age=14400, s-maxage=300even though the Worker sendsmax-age=0, s-maxage=300. Cloudflare’s CDN cached the response because ofs-maxageand the zone’s Browser Cache TTL setting rewrote the browser TTL to four hours. That left the server-rendered feed cacheable in browsers for much longer than the intended five minutes.Fix
platforms/cloudflare/src/index.ts.Cache-Control: public, max-age=300; the response returned to clients is alwaysCache-Control: private, no-storeon both a cache miss and a Cache API hit.Verification
Cache-Control: private, no-storewithContent-Type: text/html; charset=utf-8.APP_VERSION: warming/, inserting a new row, then requesting/returned the cached HTML without the new row; a fresh cache key (/?cacheprobe=1) did include it. The internal five-minute Cache API still works./inreader-shell-v142withCache-Control: private, no-storeand the full 131 KB HTML, so offline reuse is intact.npm run typechecknpm test— 87 passingnpm audit— 0 vulnerabilitieswrangler deploy --dry-runProduction verification
After deploy,
curl -sI https://reader.boringcode.dev/should returncache-control: private, no-storeandcf-cache-status: BYPASS/DYNAMICrather thanHIT. The Worker Cache API still serves the five-minute copy.🤖 Generated with Claude Code