Prevent page caches from storing content-negotiation redirect#31
Open
TBarregren wants to merge 1 commit intoProgressPlanner:mainfrom
Open
Prevent page caches from storing content-negotiation redirect#31TBarregren wants to merge 1 commit intoProgressPlanner:mainfrom
TBarregren wants to merge 1 commit intoProgressPlanner:mainfrom
Conversation
Full-page caches (LiteSpeed Cache, WP Super Cache, etc.) ignore the Vary: Accept header and cache the 303 redirect keyed by URL alone, causing all visitors to be redirected to the .md URL. Add three cache-prevention layers before the redirect: - DONOTCACHEPAGE constant (universal WP cache convention) - Cache-Control: private, no-store (HTTP standard for proxies/CDNs) - litespeed_control_set_nocache action (LSCWP API, no-op if inactive) The .md URLs themselves remain fully cacheable. Fixes ProgressPlanner#30 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
Hmm this solution would prevent caching everywhere, including in solutions that do understand they should... vary cache, by |
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.
Summary
Vary: Acceptheader and store the 303 redirect fromhandle_accept_negotiation()keyed by URL alone.mdURL instead of seeing the HTML pageThe Fix
Three complementary layers added before the redirect in
handle_accept_negotiation():DONOTCACHEPAGEconstantCache-Control: private, no-storedo_action('litespeed_control_set_nocache')The
.mdURLs themselves remain fully cacheable — only the content-negotiation redirect (which depends on theAcceptheader) is excluded from caching.Test Plan
Accept: text/markdownreturns 303 withCache-Control: private, no-store:curl -sI -H "Accept: text/markdown" https://example.com/some-page/.mdURL returns 200 withtext/markdowncontent type:Fixes #30
Relates to PITFALLS.md Pitfall #5 ("Content Negotiation Interferes with Caching")
🤖 Generated with Claude Code