Jump to content

Quiet save and caching


gRegor
 Share

Recommended Posts

I'm using "quiet" saving in the Webmention module and was wondering if that prevents the page's cache from being cleared. I'm just using the built-in page caching with the option "Clear cache for saved page only (default)"

If it matters, the page-save I'm calling is specifying the Webmention Field, rather than just $page->save();

For reference, the code is https://github.com/gRegorLove/ProcessWire-Webmention/blob/master/Webmention/Webmention.module#L840

Link to comment
Share on other sites

Actually, I just experienced this “problem” where I’m saving an image field using $page->save('images') and even in non-quiet mode it didn’t invalidate the one-week template cache. That’s on a 2.7.2 installation. So the answer to your question seems to be Yes, it does prevent the cache from being cleared.

I’m putting “problem” in quotes because I don’t really care one way or the other in this particular instance, but my user got confused (as always with caching).

Link to comment
Share on other sites

I was hoping for more explanation of quiet saving instead of just experimentation. I did just experiment though and it doesn't seem to clear the cache. :) It sounds like it's a bug based on that and Jan's report; I'll dig into core code.

Link to comment
Share on other sites

  • 2 weeks later...

After more digging and experimenting, I found the functionality I was looking for is (a bit un-intuitively) in the PageRender module. There's methods in there that hook into Pages::save, get the CacheFile for the page, and clear it. Since the method clearCacheFile() is a hook call and not intended to be called directly, I ended up doing this in my module after saving fields:

$PageRender = $this->wire('modules')->get('PageRender');
$cf = $PageRender->getCacheFile($page);

if ( $cf->exists() )
{
	$cf->remove();
}

Some of my earlier experimentation was calling $this->wire('cache')->maintenance(), but I realized that's WireCache which is different than the cached files created for pages.

  • Like 1
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...