sg_cachepress_purge_cache issue
-
Hi
We have a faux multisite setup, so instead of a multisite, we use a Custom Post Type (website) to store information about each subsite (like a website_url meta field etc).
Whenever a website post is saved, we call the
sg_cachepress_purge_cache( $website_url );function to clear the cache. But this does only clear the cache for the main website URL.
Let’s say I have these websites: website.com, x.website.com and y.website.com. If my admin is logged in on website.com (main website) and is editing the post of x.website.com, we execute this after saving the post:sg_cachepress_purge_cache( 'https://x.website.com/' );But when we then navigate to x.website.com, the changes we made are not visible and a previously cached version is shown.
After some digging, I found out that the
Supercacher::purge_cache_request( $url, $include_child_paths );function is executed. In this function the hostname is parsed from thehome_url();and not from the url parameter. Then theSupercacher::flush_dynamic_cache( $hostname, $main_path, $url );function is executed.
In my case, the flush_dynamic_cache would look like this:Supercacher::flush_dynamic_cache( 'website.com', '/(.*)', 'https://x.website.com/' )And it should be this (based on the URL):
Supercacher::flush_dynamic_cache( 'x.website.com', '/(.*)', 'https://x.website.com/' )For now I was able to fix this by directly calling the flush_dynamic_cache function after a post save like this:
\SiteGround_Optimizer\Supercacher\Supercacher::flush_dynamic_cache( 'x.website.com', '/(.*)', 'https://x.website.com/' );Is is intended that the hostname gets parsed from the home_url? Because I would like to use
sg_cachepress_purge_cache( 'https://x.website.com/' );, so it makes more sense to me that the hostname should be parsed from the URL I provided.Is is also possible to flush the dynamic cache of multiple subsites (parked domains) in one request? Something like this:
flush_dynamic_cache( '*.website.com', '/(.*)' );
Thanks!
The topic ‘sg_cachepress_purge_cache issue’ is closed to new replies.