Configure request headers used in cache keys - #800
Open
maxschmeling wants to merge 17 commits into
Open
Conversation
Contributor
|
Test this PR in WordPress Playground. |
chriszarate
reviewed
Aug 18, 2026
chriszarate
reviewed
Aug 18, 2026
chriszarate
reviewed
Aug 18, 2026
chriszarate
reviewed
Aug 18, 2026
chriszarate
reviewed
Aug 18, 2026
chriszarate
reviewed
Aug 18, 2026
Co-authored-by: Chris Zarate <chris.zarate@automattic.com>
chriszarate
reviewed
Aug 18, 2026
chriszarate
reviewed
Aug 18, 2026
chriszarate
reviewed
Aug 18, 2026
| parent::__construct( | ||
| $storage ?? new WordPressObjectCacheStorage( self::WP_OBJECT_CACHE_GROUP ), | ||
| self::FALLBACK_CACHE_TTL_IN_SECONDS, | ||
| $vary_headers |
Member
There was a problem hiding this comment.
Cache poisoning is still possible in the future. The vary headers passed to the constructor ([]) and the ones used in get_object_cache_key_from_request are different. That is why I suggested porting the code from GreedyCacheStrategy and no longer extending it. I don't think we can honor its contract.
Contributor
Author
chriszarate
reviewed
Aug 18, 2026
chriszarate
reviewed
Aug 18, 2026
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
cache_key_request_headersconfiguration for HTTP queriesAuthorizationandCache-Control, merging additional query header names case-insensitivelyget_cache_key_request_headers()part ofHttpQueryInterfaceand haveQueryRunnerconsume the query-owned policy directlySecurity
Remote Data Blocks does not include every request header in cache keys. If a custom header changes authentication, authorization, tenancy, or returned data, every query that uses it must list that header in
cache_key_request_headers; otherwise requests with different security contexts can share a cached response.Headers configured on a data source are not added automatically. The documentation calls this out prominently, including the cross-request and cross-user risk with persistent object caching. The built-in
AuthorizationandCache-Controldefaults cannot be removed.Compatibility
Direct implementations of
HttpQueryInterfacemust implementget_cache_key_request_headers(). Returning[]uses only the built-in defaults. The extending guide includes an upgrade example.Testing
npm run format:checknpm run lint:phpnpm run lint:jsnpm run check-typesnpm test(596 PHP tests / 1,374 assertions; 76 JavaScript tests)npm run buildgit diff --check