Add views render caching on views ajax requests

Created on 4 June 2015, over 9 years ago
Updated 11 April 2023, over 1 year ago

Problem/Motivation

#2381277: Make Views use render caching and remove Views' own "output caching" β†’ replaces output caching with render caching.
Render caching though is disabled on POST requests, so that ajax requests aren't cacheable.

We need to get πŸ“Œ Allow AJAX to use GET requests Fixed in, to be able to get render caching done.

Proposed resolution

- Add setting for query type to views pagers
- Make views pager respect that setting so that it uses the correct protocol
- Get render caching to work on views AJAX paging responses

Remaining tasks


- Get πŸ“Œ Allow AJAX to use GET requests Fixed committed
- Verify that we have enough test coverage on this issue
- QA testing to get to RBTC

User interface changes

I added a "pager query type" selector to sql-base pagers which becomes active if you set the view to use AJAX.

API changes

- Added a "getParam" method to ViewAjaxController to make it easier to get parameters off of a request.

How to test

- Install a new site
- Apply most recent patch from this issue (currently: https://www.drupal.org/files/issues/2500313--views-get-paging-support-83... β†’ )
- Apply https://www.drupal.org/files/issues/ajax-956186-65_2x_1.patch β†’ from πŸ“Œ Allow AJAX to use GET requests Fixed
- Create at least five articles
- Create two views as follows

View 1
- Add a block display
- Call it "GET pager view"
- List all nodes
- Turn on AJAX for the view
- Use a pager (try them all if you can); 2 per page, set query type to GET

View 2
Same as View 1, except:
- Call it "POST pager view"
- Set query type on the pager settings to POST

Now:
- Place both blocks somewhere on the page
- Start using the pager, and use the network tab (helpful to filter by XHR) to ensure that the views are using the correct protocol for their requests.

Some other things to try:
- Using a table display, ensure that column sorting is respected after paging back and forth.
- Add an exposed filter and make sure paging works after the setting the filter value.
- Test the render caching somehow. Make sure page cache is turned on, and put a breakpoint or something inside a function that runs when rendering a row. The breakpoint should hit a) when the cache is first populated and b) if something invalidates the cache (i.e. that node is updated).

πŸ“Œ Task
Status

Closed: outdated

Version

9.5

Component
ViewsΒ  β†’

Last updated about 12 hours ago

Created by

πŸ‡©πŸ‡ͺGermany dawehner

Live updates comments and jobs are added and updated live.
  • VDC

    Related to the Views in Drupal Core initiative.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom catch

    Postponing on πŸ“Œ Allow AJAX to use GET requests Fixed .

  • Status changed to Needs work over 1 year ago
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Unblocked!

  • πŸ‡¬πŸ‡§United Kingdom catch

    I think we actually don't need to do this any more - πŸ“Œ Allow AJAX to use GET requests Fixed already converted Views since it was the main (only) use-case for non-form AJAX in core, so Views is using GET for pagers etc. in Drupal 10.1 already.

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    It's using GET AJAX requests indeed, but the scope of this issue seems to also stress the need to add render caching in that situation. But perhaps that's already happening? πŸ˜„

    (I could investigate/verify that too but it's been ages since I've looked at Views' render pipeline, it'd probably take you only a few dozen seconds to check? πŸ€“πŸ˜…)

    If that's already happening too, then I definitely agree this can be closed (as a duplicate?).

  • Status changed to Closed: outdated over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    Views render caching is just normal render caching now, that's why this issue was opened in the first place!

    Drupal 7: Views has its own HTML caching pipeline, which works on POST requests, but doesn't handle any of the things Drupal 8+ render caching does like cache tags etc.

    Drupal 8+: Views uses core render caching, which is great for normal GET requests, but skips caching on POST requests.

    Drupal 10.1: cache cache cache cache cache cache!

    Closing as outdated.

Production build 0.71.5 2024