Skip Navigation

[Resolved] Updating View page cache on the fly

This thread is resolved. Here is a description of the problem and solution.

Problem:

Are there any API calls to update the page caches for Views on the fly?

Solution:

There isn't API call can update the view's cache, see our document:

https://toolset.com/documentation/programmer-reference/views-api/

But you can disable Views cache by adding attribute cached="off" in Views shortcode, for example:
[wpv-view name="My view name" cached="off"]

Relevant Documentation:

This support ticket is created 4 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by catherineR-2 4 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1419601
Screen Shot 2019-12-21 at 10.49.09 AM.png

Hi,

We have a View that's showing 1 post per page. The user can favorite/unfavorite a post (the heart in the attached image). For speed, we have the page caching turned on in the View.

If a user is viewing a post, and they click the heart icon, it correctly tags the post through Ajax and updates the icon state through jQuery. But, of course, if the user navigates away and then back to that post, it's not showing the right icon, since Toolset is fetching the page from the cache.

I could add some javascript to the View to update the view's innerHTML on the fly:

jQuery( document ).on( 'js_event_wpv_pagination_completed', function( event, data ) {...}

but there would be a flash of the icon where it first loads the cache and then my code changes it.

Are there any API calls to update the page caches for Views on the fly? If not, and if the cache is stored as transients in the options table, can you let me know the option name, or any other suggestions for the best way to accomplish what I'm doing.

best regards,
Zubin

#1421417

Dear Zubin,

There isn't API call can update the view's cache, see our document:
https://toolset.com/documentation/programmer-reference/views-api/
But you can disable Views cache by adding attribute cached="off" in Views shortcode, for example:
[wpv-view name="My view name" cached="off"]

See our document:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-view
cached (opt):
off
Turns off the caching system for the View.

#1422183

Thanks, I don't want to turn off the cache. But I will do my own solution via javascript.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.