Skip to content

fix: keep REST API responses out of page caches - #600

Merged
lightbulbman merged 2 commits into
core-betafrom
fix/rest-cache-bypass/core
Oct 19, 2026
Merged

lightbulbman merged 2 commits into
core-betafrom
fix/rest-cache-bypass/core

Conversation

@lightbulbman

Copy link
Copy Markdown
Contributor

Summary

Page caches were storing and replaying responses from the plugin's REST API. With LiteSpeed Cache active, the snippet list re-read after an activation toggle returned stale data until the cache was purged.

Changes

  • Add REST_Cache_Bypass, registered with the REST controllers. On rest_post_dispatch, for any route under code-snippets/v*, it:
    • sets Cache-Control, Pragma, Expires, X-LiteSpeed-Cache-Control, X-Accel-Expires, Surrogate-Control, CDN-Cache-Control, Cloudflare-CDN-Cache-Control and X-Cache-Enabled on the response;
    • defines DONOTCACHEPAGE and fires litespeed_control_set_nocache.
  • Add the code_snippets/rest_api/bypass_cache filter to switch the behaviour off.
  • Append a timestamp query parameter to every GET sent through the shared axios instance.

Routes outside the plugin's namespace are not modified.

Verification

  • PHPUnit: new REST_Cache_Bypass_Test; full suite passes on this branch (364 tests, 25 skipped).
  • PHPCS and ESLint pass on the changed files.
  • Not verified against a server running LiteSpeed Cache or another page cache.

@lightbulbman
lightbulbman merged commit 69c8f64 into core-beta Oct 19, 2026
10 checks passed
@lightbulbman
lightbulbman deleted the fix/rest-cache-bypass/core branch October 19, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant