Problem/Motivation

Views by default uses the full url or all the query arguments to create the result key whenever there are exposed filters or pager options. This will also include unrelated values (e.g. dom id on ajax requests or tracking values). This in effect will negate cacheability on ajax views.

Steps to reproduce

- Create view with filters and ajax.
- Access view and filter via ajax. The request includes the dom_id, which is included in the result key.
- Reload the page with the view. The dom_id has changed, so the previous result is not used.

Proposed resolution

- Change pager and filter plugins to return specific cache contexts on their query arguments
- Add cache context for ajax requests as the output might differ from a page load
- Update tests to check for correct cache contexts

Remaining tasks

- Review and refine proposed functional patch
- Rework tests to match expected output.

User interface changes

None

API changes

- Adds a new ajax cache context

Data model changes

None

Release notes snippet

Issue fork drupal-3425345

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pvbergen created an issue. See original summary.

pvbergen’s picture

Title: Views: Use precise arguments for result key » Views caching: Use precise arguments for result key
pvbergen’s picture

Issue summary: View changes
pvbergen’s picture

pvbergen’s picture

Issue summary: View changes

pvbergen’s picture

Issue summary: View changes
cilefen’s picture

This seems related.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.