[FIX] Interoperability with CF Workers plugin
-
Because CF Free doesn’t support
cookie-bypass
, and CF Super Page Cache (WPCSPC) doesn’t yet support a cookies-bypass filter either, have been looking into a workaround thanks to CF Workers via this plugin (ECHCW).At glance, ECHCW does the
cookie-bypass
thing and works reasonably well so far, but already noticed it has the following drawbacks:
a) The Worker implementation still needs of the “cache-everything” page rule, otherwiseCF-Cache-Status: DYNAMIC
is returned for every response (at least for my use case)
b) Also encountered issues ofwp-admin
getting cached, so had to add yet another page rule to fix that one too
c) The Workers script implements a fine-grained cache purge based onKV Namespaces
, but that CF facility isn’t free anymore, unfortunately. The other option available in the script is a “purge-everything” happening each time something gets updated at the origin, which is suboptimal and wasteful.Those shortcomings mesh well with WPCSPC’s strengths, and vice-versa, so it’s gainful for everyone to consider integrating both plugins (at least until WPCSPC gets ready with its own flavor of Workers).
Looking at the code of the sidekick plugin that does the origin’s page-caching (CFPC), it easily becomes apparent the process of invoking the Worker is quite straightforward; CFPC just inserts this code during init to fire up everything else at the Edge:
if( !is_user_logged_in() ) { header( 'x-HTML-Edge-Cache: cache,bypass-cookies=wp-|wordpress|comment_|woocommerce_' ); } else { header( 'x-HTML-Edge-Cache: nocache' ); }
The remaining code of CFPC manages the various purge cases happening at WP, by setting and additional
header('x-HTML-Edge-Cache: purgeall')
, but as already stated above, purging that way isn’t of much use without aKV namespace
, so WPCSPC API approach should apply anyway.Summarizing, WPCSPC could become ECHCW’s new and improved “sidekick” instead of CFPC, by only adding 2 lines of code in
cache_controller.class.php
, namely:if( $this->skip_cache ) return; #--> if( !is_user_logged_in() ) header('x-HTML-Edge-Cache: cache,bypass-cookies=wp-|wordpress|comment_|woocommerce_'); #<-- if( $this->is_url_to_bypass() ) { header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("X-WP-CF-Super-Cache: no-cache"); header('X-WP-CF-Super-Cache-Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); #--> header('x-HTML-Edge-Cache: nocache'); #<-- $this->skip_cache = true; return; }
It seems working well for me so far.
HTH.
- The topic ‘[FIX] Interoperability with CF Workers plugin’ is closed to new replies.