pcfreak30/wp-criticalcss

WPEngine integration clears varnish cache on each /nocache/ hit

Opened this issue · 0 comments

The WPEngine integration appears to clear the page's varnish cache on each hit to a /nocache/ link, using the wp_criticalcss_nocache action. This was added in 69c7926

Since the Web Check Queue hits the /nocache/ links, isn't the varnish cache being cleared every time the web check is done, regardless of whether there's page change to pass to the API Queue?

Would it be beneficial to instead duplicate the modify_permalink() function from the Kinsta integration, and add a cache_bust query argument?

if ( wp_doing_cron() ) {
add_filter( 'wp_criticalcss_get_permalink', [ $this, 'modify_permalink' ] );
}
}

public function modify_permalink( $url ) {
$key = 'cache_bust_' . bin2hex( random_bytes( 5 ) );
return add_query_arg( $key, '1', $url );
}

Apologies if I'm missing the purpose of the cache clear.