Hi Team - I am trying to understand how only 1 of the View is cached, but all of the other ones are not. I know it's only a View of a hyperlink vs. a View of Taxonomy terms, but wouldn't they both be the same?
hidden link
Hi,
Thank you for contacting us and I'd be happy to assist.
The way the built-in cache feature works for views, you can force it in two ways:
a). In a view created using the Blocks editor, you'll find a "Cache View" option under the main "View" block's settings.
( screenshot: hidden link )
b). For a view created using the classic views editor, you can force cache through cached="force" attribute in the views shortcode.
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view )
Example:
[wpv-view name="slug-of-view" cached="force"]
It is important to note however that there are certain conditions, which will force the view to not use the cached version, for example:
- if the view is using front-end sorting controls
- If the view contains a query filter that listens to the URL parameter
- if the view contains a nested view or a content template
- if the view is set to show posts in a random order
- if the view contains the "conditional" block
I hope this information helps and please let me know if you need any further assistance around this.
regards,
Waqar
Thank you Waqar! If I force the cache to be "force cached", then how would I make sure it is un-cached when I need it to?
I ask because as I am currently developing... I don't need it cached (actually - just the opposite!) But when it's in production... I would like to cache as much as possible.
On a production website where you'd like to make use of view's built-in cache feature, you can follow the steps from my last message.
And, to avoid view's built-in cache, on a development website you can disable the "Cache View" option in the Blocks based views and set cached="off" if you're using the view's shortcode:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view )
[wpv-view name="slug-of-view" cached="off"]
Hi Waqar,
Great, that is good to know. I'd like to suggest a UX improvement to make the workflow better.
If I have to do cached="off" for _each_ view I create, it will be a pain to go into each View and change that from 'off' to 'forced' or neutral. Especially if you have 30+ Views and have to flip them all (and even back if needed.)
Is there some sort of bulk function that could help make the UX/process better? If not, could this be a Feature Request?
Thank you!
Thanks for writing back.
I'm afraid, there is no bulk control or setting available for this, but, I'll be happy to pass this on internally.
Thank you Waqar! If you could help pass along the suggestion of bulk control, that'd be appreciated.
>> It is important to note however that there are certain conditions, which will force the view to not use the cached version, for example:
- if the view contains a nested view or a content template
- if the view is set to show posts in a random order
- if the view contains the "conditional" block
Also, for the below, do you know if there are any plans to integrate deeper with software like Redis, NGINX, LiteSpeed so that these cache can be sync'd/linked and taken up by them? If not, could I put in a feature request for consideration?