Jump to content

Conditionally disable Template Cache in Template Context


hettiger
 Share

Recommended Posts

Hey there,

I need to temporarily disable the template cache within template context. Since throwing a Wire404Exception effectively holds up the template cache I think it should be possible somehow. Anyways no luck so far ...

I basically wan't to handle all kinds of errors myself and return a error message as json within the catch blocks of try & catch.
If i just throw the Wire404Exception I'll get html with a json header. (Template is set to return json because otherwise I can't define the header when using template cache)
Just throwing a Wire404Exception all the time is no real solution thought. It's dirty and not every error is a 404.

Thank you for your help in advance :-) 

Link to comment
Share on other sites

21 hours ago, SteveB said:

Based on this maybe try...


$page->template->cache_time = 0; // disable the cache

Thank you SteveB, unfortunately that doesn't work for me.

I've also tryed:

wire()->fuel('session')->set('PageRenderNoCachePage', $page->id);

It will disable the cache, yes. But it will still cache the current request.
I want to be able to prevent caching the current request within template scope. Any future requests may not be influenced.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...