- Issue created by @watergate
- Merge request !6Set cache context based on the configured/allowed query arguments. → (Open) created by watergate
- Status changed to Needs review
8 months ago 2:30pm 22 March 2024
When not using JavaScript to forward the query arguments, the url.query_args
cache context is added to pages. This means that different query argument values create new cache entries, even for query arguments that are not forwarded (and so don't create different cached content).
This bug is tedious on sites using query arguments for search in combination with facets. Each different search query invoked by visitors causes cache entries to be created for the rendered entities/results (and being identical to each other). This will flood the cache bins and hurt performance (as the rendered entities shown on the page are only served from the cache when the search query matches and not when they are shown for a different search and facet combination).
Assuming a typical Drupal setup, where (render) caching is enabled, the "Carry URL address query params across pages" module is installed. Navigate to a page, e.g., an article node, and verify that a cache entry is stored in the render cache bin. Add a query argument to the URL, e.g., ?foo
, and verify that a new cache entry is stored in the render cache bin, while foo
is not carried across rendered URLs.
Add the allowed/configured query argument keys to the cache context ID, i.e., url.query_args:foo
where 'foo' is a configured key that has to be carried over. This way, only the query arguments that influence page content (the URLs having the query arguments attached) change the cache context.
None
None
None
Needs review
1.0
Code