Skip to content

Keep mismatched Accept headers out of the LiteSpeed cache - #3969

Merged
pfefferle merged 1 commit into
trunkfrom
fix/litespeed-vary
Oct 27, 2026
Merged

pfefferle merged 1 commit into
trunkfrom
fix/litespeed-vary

Conversation

@pfefferle

Copy link
Copy Markdown
Member

Fixes #

Proposed changes:

  • The LiteSpeed rewrite rule puts a request into the JSON cache bucket when an ActivityPub type comes first in Accept, while the plugin picks the representation by quality (accept_prefers_activitypub()). For headers where the two disagree, a response could be cached in the other representation's bucket.
  • Litespeed_Cache::maybe_disable_cache() runs on template_redirect when LiteSpeed Cache is active and calls litespeed_control_set_nocache when the rule and the plugin disagree. Requests where both agree stay cacheable as before.
  • The rule pattern is now the ACCEPT_PATTERN constant, used by the rule and by the check. The rule text is unchanged, so existing .htaccess files are not rewritten.

Other information:

  • Have you written new tests for your changes, if applicable?

I did not widen the rewrite rule, because a RewriteCond cannot rank by quality, and a broader rule would mix the buckets again (see #3596 and #3601).

Testing instructions:

  • vendor/bin/phpunit --filter Test_Litespeed_Cache
  • With LiteSpeed Cache active, request a post with Accept: text/html;q=0.1, application/activity+json and check that the response has X-LiteSpeed-Cache-Control: no-cache, and that a normal browser request still gets the cached HTML.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

@pfefferle pfefferle self-assigned this Oct 27, 2026
@pfefferle
pfefferle requested a review from a team October 27, 2026 16:36
@github-actions github-actions Bot added [Focus] Compatibility Ensuring the plugin plays well with other plugins [Tests] Includes Tests labels Oct 27, 2026
@pfefferle
pfefferle merged commit 9b91cc4 into trunk Oct 27, 2026
11 checks passed
@pfefferle
pfefferle deleted the fix/litespeed-vary branch October 27, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Focus] Compatibility Ensuring the plugin plays well with other plugins [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant