Hey, it's great to see you have Super Page Cache for Cloudflare active for a few days now. How is everything going? If you can spare a few moments to rate it on WordPress.org it would help us a lot (and boost my motivation). Cheers!

~ Bogdan, developer of Super Page Cache for Cloudflare

Super Page Cache for Cloudflare

1
2
3

Enter your Cloudflare's API key and e-mail

You don't know how to do it? Follow these simple four steps:

  1. Log in to your Cloudflare account and click on My Profile
  2. Click on API tokens, scroll to API Keys and click on View beside Global API Key
  3. Enter your Cloudflare login password and click on View
  4. Enter both API key and e-mail address into the form below and click on Update settings

Enter your Cloudflare's API token

You don't know how to do it? Follow these simple steps:

  1. Log in to your Cloudflare account and click on My Profile
  2. Click on API tokens > Create Token > Custom Token > Get started
  3. Enter a Token name (example: token for example.com)
  4. Permissions:
    • Account - Account Settings - Read
    • Account - Worker Scripts - Edit
    • Zone - Cache Purge - Purge
    • Zone - Page Rules - Edit
    • Zone - Zone Settings - Edit
    • Zone - Zone - Edit
    • Zone - Worker Routes - Edit
  5. Account resources:
    • Include - All accounts
  6. Zone resources:
    • Include - Specific zone - your domain name
  7. Click on Continue to summary and then on Create token
  8. Enter the generated token into the form below and click on Update settings

Cloudflare General Settings

Authentication mode to use to connect to your Cloudflare account.
The email address you use to log in to Cloudflare.
The Global API Key extrapolated from your Cloudflare account.
The API Token extrapolated from your Cloudflare account.
Select/add the domain name for which you want to enable the cache exactly as reported on Cloudflare, then click on Update settings.
Enable this option if you want log all communications between Cloudflare and this plugin.

Cache lifetime settings

Don't touch if you don't know what is it. Must be greater than zero. Recommended 31536000 (1 year)
Don't touch if you don't know what is it. Must be greater than zero. Recommended a value between 60 and 600

Cache behavior settings

Example: update/publish a post/page: it is recommended to add the browser caching rules that you find on this page after saving these settings.
Purge cache for related pages only - (recommended)
Purge whole cache
Page 404 (is_404) - (recommended)
Single posts (is_single)
Pages (is_page)
Front Page (is_front_page)
Home (is_home)
Archives (is_archive)
Tags (is_tag)
Categories (is_category)
Feeds (is_feed) - (recommended)
Search Pages (is_search) - (recommended)
Author Pages (is_author)
AMP pages
Ajax requests - (recommended)
Pages with query args
WP JSON endpoints
Writes into .htaccess

If you only use Nginx: it is recommended to add the browser caching rules that you find on this page after saving these settings.
XML sitemaps - (recommended)
Robots.txt - (recommended)
One URI per line. You can use the * for wildcard URLs.
Example: /my-page
/my-main-page/my-sub-page
/my-main-page*
Cloudflare will not cache when there are cookies in responses unless you strip out them to overwrite the behavior.
If the cache does not work due to response cookies and you are sure that these cookies are not essential for the website to works, enable this option.
Enter how many posts per page (or category) the theme shows to your users. It will be use to clean up the pagination on cache purge.
Writes into .htaccess

This option is useful if you use Super Page Cache for Cloudflare together with other performance plugins that could affect the Cloudflare cache with their cache-control headers. It works automatically if you are using Apache as web server or as backend web server.

This option is not essential and must be disabled if enabled the Workers mode option. In most cases this plugin works out of the box. If the page cache does not work after a considerable number of attempts or you see that max-age and s-maxage values of X-WP-CF-Super-Cache-Cache-Control response header are not the same of the ones in Cache-Control response header, activate this option.

Read here if you use Apache (htaccess): for overwriting to work, make sure that the rules added by Super Page Cache for Cloudflare are placed at the bottom of the htaccess file. If they are present BEFORE other caching rules of other plugins, move them to the bottom manually.

Read here if you only use Nginx: it is not possible for Super Page Cache for Cloudflare to automatically change the settings to allow this option to work immediately. For it to work, update these settings and then follow the instructions on this page.
Read here: by default, all back-end URLs are not cached thanks to some response headers, but if for some circumstances your backend pages are still cached, you can enable this option which will add an additional page rule on Cloudflare to force cache bypassing for the whole Wordpress backend directly from Cloudflare. This option will be ignored if worker mode is enabled.
Purge only the cached HTML pages instead of the whole Cloudflare cache (assets + pages).
By default this plugin purge the cache after 10 seconds from the purging action, to avoid a high number of purge requests in case of multiple events triggered by third party plugins. This is done using a classic Wordpress scheduled event. If you notice any errors regarding the scheduled intervals, you can deactivate this mode by enabling this option.

Cloudflare Workers

This is a different way of using Cloudflare as a page caching system. Instead of page rules, you can use Cloudflare workers. This mode is only recommended if there are conflicts with the current web server or other plugins, as it is not 100% free.
Use Cloudflare Worker instead of page rule.
One cookie per line.

Read here: to apply the changes you will need to purge the cache after saving.

Fallback page caching

This is a traditional page cache on disk but which follows the same rules of the cache on Cloudflare set with this plugin. It is very useful when Cloudflare on its own initiative decides to invalidate a few pages from its cache. Thanks to this function you will no longer need to use other page caching functions of other plugins.

If you enable the fallback page cache is strongly recommended disable all page caching functions of other plugins.
Use cURL instead of Wordpress advanced-cache.php to generate the fallback page. It can increase the time it takes to generate the fallback cache but improves compatibility with other performance plugins.
Enter 0 for no expiration.
Enter a value in seconds.
One URI per line. You can use the * for wildcard URLs.
Example: /my-page
/my-main-page/my-sub-page
/my-main-page*

URIs exluded for the Cloudflare Cache are automatically excluded for the fallback cache.
One cookie name per line. These strings will be used by preg_grep.
Save response headers together with HTML code.
The following response header will never be saved: cache-control, set-cookie, X-WP-CF-Super-Cache*

Browser caching

This option is useful if you want to use Super Page Cache for Cloudflare to enable browser caching rules for assets such like images, CSS, scripts, etc. It works automatically if you use Apache as web server or as backend web server.
Writes into .htaccess

Read here if you only use Nginx: it is not possible for Super Page Cache for Cloudflare to automatically change the settings to allow this option to work immediately. For it to work, update these settings and then follow the instructions on this page.

If you are using Plesk, make sure you have disabled the options "Smart static files processing" and "Serve static files directly by Nginx" on "Apache & Nginx Settings" page of your Plesk panel or ask your hosting provider to update browser caching rules for you.

Preloader

Choose the URLs preloading logic that the preloader must use. If no option is chosen, the most recently published URLs and the home page will be preloaded.
Preload all internal links in Main WP menu
Preload all internal links in Secondary WP menu
Preload all internal links in منوی اصلی WP menu
Preload last 20 published/updated posts, pages & CPTs combined
One sitemap per line.
Example: /post-sitemap.xml
/page-sitemap.xml
Start preloading the pages of your website to speed up their inclusion in the Cloudflare cache. Make sure the cache is working first.

If you want start the preloader at specific intervals decided by you, you can create a cronjob that hits the following URL:

https://teoremenerji.com.tr/fa?swcfpc=1&swcfpc-preloader=1&swcfpc-sec-key=MmkgLZpm9NiEBn24qsZm

Secret key to use to start the preloader via URL. Don't touch if you don't know how to use it.

Varnish settings

Enable this option if you are using Varnish on Cloudways.

Other

WooCommerce settings Active plugin

Cart (is_cart) - (recommended)
Checkout (is_checkout) - (recommended)
Checkout's pay page (is_checkout_pay_page) - (recommended)
Product (is_product)
Shop (is_shop)
Product taxonomy (is_product_taxonomy)
Product tag (is_product_tag)
Product category (is_product_category)
WooCommerce page (is_woocommerce)
My Account page (is_account) - (recommended)

Easy Digital Downloads settings Inactive plugin

Primary checkout page - (recommended)
Purchase history page - (recommended)
Login redirect page - (recommended)
Success page
Failure page

Autoptimize settings Inactive plugin

W3 Total Cache settings Inactive plugin

W3TC flushs all caches - (recommended)
W3TC flushs database cache
W3TC flushs fragment cache
W3TC flushs object cache
W3TC flushs posts cache
W3TC flushs minify cache

LiteSpeed Cache settings Inactive plugin

LiteSpeed Cache flushs all caches - (recommended)
LiteSpeed Cache flushs Critical CSS
LiteSpeed Cache flushs CSS and JS cache
LiteSpeed Cache flushs object cache
LiteSpeed Cache flushs single post cache via API

Hummingbird settings Inactive plugin

WP-Optimize settings Active plugin

It is strongly recommended to disable the page caching functions of other plugins. If you want to add a page cache as fallback to Cloudflare, enable the fallback cache option of this plugin.

Flying Press settings Inactive plugin

WP Rocket settings Inactive plugin

WP Rocket flushs all caches - (recommended)
WP Rocket flushs single post cache - (recommended)
WP Rocket flushs cache directories - (recommended)
WP Rocket flushs files - (recommended)
WP Rocket flushs cache busting - (recommended)
WP Rocket flushs minified files - (recommended)
CCSS generation process ends - (recommended)
RUCSS generation process ends - (recommended)

WP Asset Clean Up settings Inactive plugin

Nginx Helper settings Inactive plugin

WP Performance settings Inactive plugin

Yet Another Stars Rating settings Inactive plugin

Swift Performance (Lite/Pro) settings Inactive plugin

Swift Performance (Lite/Pro) flushs all caches - (recommended)
Swift Performance (Lite/Pro) flushs single post cache - (recommended)

Siteground SuperCacher settings Inactive plugin

WP Engine settings Provider not detected

SpinupWP settings Provider not detected

Kinsta settings Provider not detected

Logs

Delete all the logs currently stored and optimize the log table.
Automatically reset the log file when it exceeded the max file size. Set 0 to never reset it.

Import/Export

Import the options of the previously exported configuration file.

Read here: after the import you will be forced to re-enter the authentication data to Cloudflare and to manually enable the cache.

Other settings

If you want purge the whole Cloudflare cache at specific intervals decided by you, you can create a cronjob that hits the following URL:

https://teoremenerji.com.tr/fa?swcfpc=1&swcfpc-purge-all=1&swcfpc-sec-key=6Ybu1bT3RVSk1hvfOHq7

Secret key to use to purge the whole Cloudflare cache via URL. Don't touch if you don't know how to use it.
If enabled, a metabox is displayed for each post type by allowing you to exclude specific pages/posts from the cache.
Redirect 301 for all URLs that for any reason have been indexed together with the cache buster. Works for logged out users only.
Admins are always allowed.
customer
shop_manager
If enabled, the browser prefetches in background all the internal URLs found in the viewport.

Purge the cache and wait about 30 seconds after enabling/disabling this option.

URIs in Prevent the following URIs to be cached will not be prefetched.

If enabled, it preloads a page right before a user clicks on it. It uses instant.page just-in-time preloading.

Purge the cache and wait about 30 seconds after enabling/disabling this option.

URIs in Prevent the following URIs to be cached will not be prefetched.

Stop adding cache buster query parameter when using the default page rule mode.

DO NOT ENABLE this option unless you are an advanced user confortable with creating advanced Cloudflare rules. Otherwise caching system will break on your website.

Check this implementation guide first before enabling this option.

Keep settings on plugin deactivation.

Common questions

Can I use this plugin to take advantage of Cloudflare's Cache Everything rule, bypassing the cache for logged in users even if I'm using the free plan?

Yes. This is the main purpose of this plugin.

Does this plugin also perform CSS and Javascript optimizations?

No, this is a caching plugin. To perform other page optimizations you can use it together with other performance plugins.

The purpose of this plugin is to get you the lowest possible response times (TTFB) by using Cloudflare as a page caching system, while maintaining full control of the cache.

What is the swcfpc=1 parameter I see to every internal links when I'm logged in?

It is a cache buster. Allows you, while logged in, to bypass the Cloudflare cache for pages that could be cached.

It is added to all internal links for logged in users only. It is disabled in Worker mode.

Can I restore all Cloudflare settings as before the plugin activation?

Yes you can by click on Reset all button.

Why all the pages have "BYPASS" as the cf-cache-status?

Cloudflare does not add in cache pages with cookies because they can have dynamic contents. If you want to force this behavior, strip out cookies by enabling the option Strip response cookies on pages that should be cached.

What is Fallback Cache?

Fallback Cache is an option to generate static HTML version of the webpages inside your site. This is a great option and can increase your site speed dramatically. The way Cloudflare works is that it will only cache a page to it's global CDN network if it has received any request for those pages. So, if you don't have fallback cache, for the first few requests, your server will be executing the pages and sending the HTML to the user, which increases slowness and latency.

Our fallback cache system follows the same standard that Cloudflare follows when it caches a page to it's CDN edge. This way we generate the HTML version of the webpage before an user has requested for that page. By doing this, when any user access the webpage for the first time, the page loads super fast as it is already loading a rendered HTML rather than waiting for the server to generate HTML and pass that to the users.

Our fallback cache system works way better than any other disk cache system and plugins out there in the market. In short now you don't need to install any other caching plugin in conjunction with Super Page Cache for Cloudflare, as the plugin can now handle Cloudflare caching and disk caching.

What is Preloader and how it works?

The preloader is a simple crawler that is started in the background and aims to preload pages so that they are cached immediately.

Once the preloader is enabled, you need to specify which preloading logic among those available to use. You can choose a combination of options (sitemaps, wordpress menus, recent published posts, etc ..).

It is also possible to automatically start the preloader when the cache is cleared.

In order to avoid overloading the server, only one preloader will be started at once. It is therefore not possible to start more than one preloader at the same time. Furthermore, between one preload and the other there will be a waiting time of 2 seconds.

If you want to run the preloader at middle of the night when you have low users, you can run the preloader over CRON job as well.

What is the difference between Purge Cache and Force purge everything actions?

If the Purge HTML pages only option is enabled, clicking on the PURGE CACHE button only HTML pages already in cache will be deleted from Cloudflare's cache.

If for some reason you need to delete static files (such as CSS, images and scripts) from Cloudflare's cache, you can do so by clicking on Force purge everything

Common issues

Error: Invalid request headers (err code: 6003 )

This is a Cloudflare authentication error. If you chose the API Key as the authentication mode, make sure you have entered the correct email address associated with your Cloudflare account and the correct Global API key (not your Cloudflare password!).

If you are chose the API Token as the authentication mode, make sure you have entered the correct token, with all the required permissions, and the domain name exactly as it appears in your Cloudflare account.

Also make sure you haven't entered the API Token instead of the API key or vice versa

Error: Page Rule validation failed: See messages for details. (err code: 1004 )

Login to Cloudflare, click on your domain and go to Page Rules section. Check if a Cache Everything page rule already exists for your domain. If yes, delete it. Now from the settings page of Super Page Cache for Cloudflare, disable and re-enable the cache.

Error: Actor 'com.cloudflare.api.token.' requires permission 'com.cloudflare.api.account.zone.list' to list zones (err code: 0 )

If you are using an API Token, check that you entered the domain name exactly as on Cloudflare

PHP Warning: Cannot modify header information - headers already sent in /wp-content/advanced-cache.php

Maybe you have some extra newline or space in other PHP files executed before advanced-cache.php such like must-use plugins or wp-config.php.

Check those files. Try the following:

  1. If you have any code inside mu-plugin take them out of that folder. Check your server error log and test to see if you are getting the header errors still.
  2. If not then check the codes inside the PHP files and see if any of them has an extra newline or space at the end of the script. If they have delete those new lines and spaces and test.
  3. If still doesn't work check if any of the scripts inside mu-plugins have print, echo, printf, vprintf etc. in the code. For more details check: https://stackoverflow.com/a/8028987/2308992

In short, the problem is not coming from this plugin but some mu-plugin is sending the header before advanced-cache.php can. That's causing the issue. We have thoroughly tested this.

Custom login page does not redirect when you login

Exclude the custom login URL by adding it into the textarea near the option Prevent the following URIs to be cached, then save, purge the cache, wait 30 seconds and retry.

Third-party integrations

Does it work with Litespeed Server?

Yes but if you are using a LiteSpeed Server version lower than 6.0RC1, disable the option Overwrite the cache-control header for Wordpress's pages using web server rules. You can keep this option enabled for Litespeed Server versions equal or higher then 6.0RC1

How does this plugin work with Kinsta Cache?

If you are using a Kinsta hosting, you can integrate this plugin to work with Kinsta Server Level Caching and to ensure when you Purge Cache via this plugin, it not only purges the cache on Cloudflare but also on Kinsta Cache. You can enable this feature by going to the "Third Party" tab of the plugin settings and enabling the "Automatically purge the Kinsta cache when Cloudflare cache is purged" option. It is also recommended that if you are taking advantage of the Kinsta Server Caching (Recommended), please ensure that the Fallback Cache system provided by this plugin is turned OFF.

After purging the cache from our plugin, it gets deleted from both Kinsta & Cloudflare Cache. Now when you visit the webpage for the first time after purging the cache, you will get cache response headers as MISS/EXPIRED etc. for both Cloudflare and Kinsta cache.

At this point after receiving the first request both Cloudflare & Kinsta caches the page on their own platforms respectively. But do note that when Cloudflare is caching the first request at this point the x-kinsta-cache header is of status MISS. For the second request when Cloudflare serves the page from it's own CDN Edge servers without sending the request to the origin server, it keeps showing the x-kinsta-cache cache header as MISS. Because when Cloudflare cached the page the response header was MISS but Kinsta caching system has already cached it upon receiving the first request.

Now if you purge the Cloudflare cache only (on Cloudflare dashboard) or enable development mode in the Cloudflare dashboard so that the request doesn't get served from Cloudflare CDN, you will see the x-kinsta-cache showing as HIT, because this time the request is going to your origin server and you are seeing the updated response headers that is being served by the server.

Can I use this plugin together with Litespeed Cache?

Yes you can! You have only to disable its page caching functionality. To do this:

  1. Go to Litespeed Cache > Cache
  2. Click on OFF near Enable Cache
  3. Click on Save Changes button

Then:

  1. Enter to the settings page of this plugin
  2. Click on Third Party tab
  3. Scroll to Litespeed Cache Settings section
  4. Enable the option Automatically purge the cache when LiteSpeed Cache flushs all caches
  5. Purge the cache

Can I use this plugin together with Autoptimize?

Yes you can! It is highly recommended to enable the option Enable 404 fallbacks of Autoptimize.

Can I use this plugin together with WP-Rocket?

Yes you can! Please follow these steps mentioned in this GitHub Gist. This will guide you to do all the things necessary in order to use WP Rocket with this plugin. Here is a summery of what you need to do:

  1. Disable WP-Rocket and make sure no advanced-cache.php files of other plugins are into wp-content directory
  2. Upload the must use plugin code (inside /wp-content/mu-plugins/ folder) provided in the GitHub Gist (link given above).
  3. Enable this plugin
  4. Enable the Fallback Cache option (If you want to use disk level fallback cache)
  5. Click on Third Party tab
  6. Scroll to WP-Rocket Cache Settings section and enable the Disable WP Rocket page cache option
  7. Purge the cache
  8. Enable WP-Rocket again
  9. Purge WP-Rocket cache

Can I use this plugin together with other page caching plugins such like Cache Enabler, WP Super Cache and WP Fastest Cache?

No. The support for these plugin was removed because you can use the fallback cache option of this plugin if you want to use a standard page cache behind Cloudflare.

In order to avoid conflicts, it is strongly recommended to use only this plugin as page caching system.

Can I use this plugin together with Varnish Cache?

Yes but you don't need it. If you want to use a standard page cache behind Cloudflare, enable the fallback cache option of this plugin.

In order to avoid conflicts, it is strongly recommended to use only this plugin as page caching system.

Cache questions and issues

WP Admin or WP Admin Bar is being cached

This should never happen. If it happens, it is because the value of the Cache-Control response header is different from that of the X-WP-CF-Super-Cache-Cache-Control response header (make sure it is the same).

If you are using LiteSpeed Server version lower than 6.0RC1, make sure the Overwrite the cache-control header for Wordpress's pages using web server rules option is disabled. If not, disable it, clear your cache and try again. You can keep this option enabled for Litespeed Server versions equal or higher then 6.0RC1

If you are not using LiteSpeed Server and you are using this plugin together with other performance plugins, enable the Overwrite the cache-control header for Wordpress's pages using web server rules option, clear the cache and try again.

If this doesn't work, you can always choose to activate the Force cache bypassing for backend with an additional Cloudflare page rule option or to change the caching mode by activating the Worker mode option.

Why changes are never showed when visiting the website?

First of all enable the log mode and check if in the log file, after clicking on the update button on the edit page, you see the information about the cache purging.

If so, good news: the plugin is working correctly. If not, open a ticket on the support forum.

If you have enabled the Fallback cache, make sure you have also enabled the option Automatically purge the fallback cache when Cloudflare cache is purged.

If you are using Varnish cache, make sure you have also enabled the option Automatically purge Varnish cache when the Cloudflare cache is purged.

Disable any other page caching plugins or services. Only use this plugin to cache HTML pages.

If you still don't see the changes despite everything, the problem is to be found elsewhere. For example wrong configuration of wp-config.php.

URLs with swcfpc=1 parameter getting indexed

In very rare cases, it may happen that some third-party plugin stores the cache buster parameter in the database, and therefore this is then also displayed to users who are not logged in and therefore to search engine bots.

If this happened on your site, enable the SEO redirect inside the plugin settings page under the Others tab. This will auto redirect any URLs which has swcfpc=1 in it to it's normal URL when any non-logged in user clicks on that link, avoiding duplicate content problems.

I am seeing ?swcfpc=1 at the front end URLs even when I'm not logged in

Some page builders might copy the admin side links and show that on the front end for all users. This happens because these page builders do not follow the standard WordPress coding guidelines to fetch URLs and instead copy hard code URLs. If you are facing this issue, you can easily fix this by enabling the SEO redirect option inside the plugin settings page under the Others tab. This will auto redirect any URLs which has swcfpc=1 in it to it's normal URL when any non-logged in user clicks on that link.

Even after enabling the plugin I'm seeing CF Cache Status DYNAMIC for all the pages

There are a couple of things that can cause this issue and tell Cloudflare not to cache everything. If you are facing this issue, please check the following this:

  • Make sure that Development Mode is NOT enabled for your domain inside Cloudflare.
  • Make sure you have the orange cloud icon enabled inside the Cloudflare DNS settings for your main domain A record and WWW record.
  • Make sure you do not have any other page rules that might conflict with the Cache Everything rule
  • Make sure you do not have any Cloudflare Worker code deployed that might overwrite the normal cache policies
  • Make sure you don't have any plugins which might be adding a lot of unnecessary Cookies in your request header for no reason. If you have any cookie consent plugin or any similar things, try disabling those plugins and check again. You can also enable the Strip response cookies on pages that should be cached option under the Cache tab to see if this resolves your issue. If it does, that means there are plugin which is injecting cookies into your site header and when Cloudflare sees these Cookies, it think that the page has dynamic content, so it doesn't cache everything.

Should I enable the cURL mode for Fallback Cache?

In most cases you don't need to enable the cURL mode for fallback cache. If you don't enable the cURL mode, the plugin will use the standard WordPress advanced-cache.php method to generate the fallback cache. This system works well in almost all the cases, also this cache generation mechanism is very fast and don't eat much server resource. On the other hand the cURL mode is useful in some edge cases where the advanced-cache.php mode of fallback cache is unable to generate proper HTML for the page. This is rare, but the cURL option is given just for these edge cases.

One of the benefit of the cURL mode is that as it uses server level cRUL instead of advanced-cache.php to generate the page cache, the cache files comes out very stable and without any issues. But then again if your enable the cURL mode, that means cURL will fetch every page of your website (which are not excluded from fallback cache) to generate the fallback cache and each cURL request is going to increase some server load. So, if you have a small to medium site with not many pages, you can definitely use the cURL mode of fallback cache. But for large high traffic website, unless you have more than enough server resource to handle so many cURL requests, we will recommend stick to using the default advanced-cache.php option which works flawlessly anyway.

What's the benefit of using Cloudflare worker over using page rules?

Cloudflare Workers is an amazing technology which allows us to run complicated logical operations inside the Cloudflare edges. So, basically before Cloudflare picks up the request, it passes through the Cloudflare worker and then we can programmatically tell Cloudflare what to do and what not to do. This gives us great control over each and every request and how Cloudflare should handle them.

The Page Rule option of Cache Everything works perfectly in almost every cases but in some situations due to some server config or other reasons, the headers that this plugin sets for each requests, does not get respected by the server and gets stripped out. In those edge case scenarios Cloudflare Worker mode can be really helpful over the page rules mode.

So, in terms of speed, you might not see a difference but the Worker mode is there just for the cases when the page rule mode is not working correctly across the whole website (frontend & backend).

Isn't Cloudflare Workers are chargeable?

Yes & No. It depends on how many visitors your site have. Cloudflare Workers have a free plan which allows 100,000 requests/day for FREE. But if your site has more requests than that per day, then you need to opt for the paid plan of $5/month which will give you 10 Million Requests/month and after that $0.50 per additional 1 Million requests.

Please note that, all requests first get intercepted by Cloudflare Worker before Cloudflare decide what to do with that request, so whether your requests gets served from Cloudflare CDN Cache or from origin, it will be counted towards your Worker usage limit.

If you have a small to medium site, you can easily use Cloudflare Worker without hesitating about payment as you will not get pass the free quota, but as you grow, and if you still want to use the Cloudflare Workers, you might have to pay for it. Cloudflare Workers are so much more and has so much power that if you are truly taking advantage of the Cloudflare Workers, your can do a lot of cool things. So, in short if you have a big high traffic site and you don't want to pay extra for the Cloudflare Workers, you should just stick with the Page Rules option.

How is the Worker Code is deployed to my Cloudflare Account?

After you enter the Cloudflare API details, we push our worker code using Cloudflare API to your Cloudflare account. You can find our Cloudflare Worker code inside the plugin's /assets/js/worker_template.js path.

Can I use this plugin with WP CLI?

Yes. Commands list: wp cfcache

Advanced questions

How to use the Remove Cache Buster Query Parameter option? Is there any implementation guides?

That is a super advanced option to use Cache Everything Cloudflare page rules without the swcfpc cache buster query parameter. This option is only for super advanced users who are confortable adding custom rules in their Cloudflare dashbord. If you are that person, this option probably will not be a good fit for you.

Also when using this option please keep in mind that some rules can only be implemented in Cloudflare Business and Enterprise account users. So, if you are a CLoudflare Free or Pro plan users, you might not be able to implement some rules.

Please check this implementation guide which comes all types of Cloudflare accounts before enabling this option.

Without implementioned these rules properly if you enable this option, it will break the cache functionality of your website.

Can I change swcfpc with another one?

Yes you can by adding the PHP constant SWCFPC_CACHE_BUSTER to your wp-config.php

Can I configure this plugin using PHP constants?

Yes you can use the following PHP constants:

  • SWCFPC_CACHE_BUSTER, cache buster name. Default: swcfpc
  • SWCFPC_CF_API_ZONE_ID, Cloudflare zone ID
  • SWCFPC_CF_API_KEY, API Key to use
  • SWCFPC_CF_API_EMAIL, Cloudflare email to use (API Key authentication mode)
  • SWCFPC_CF_API_TOKEN, API Token to use
  • SWCFPC_PRELOADER_MAX_POST_NUMBER, max pages to preload. Default: 50
  • SWCFPC_CF_WOKER_ENABLED, true or false
  • SWCFPC_CF_WOKER_ID, CF Worker ID
  • SWCFPC_CF_WOKER_ROUTE_ID, route ID
  • SWCFPC_CF_WOKER_FULL_PATH, full path to worker template to use
  • SWCFPC_CURL_TIMEOUT, timeout in seconds for cURL calls. Default: 10
  • SWCFPC_PURGE_CACHE_LOCK_SECONDS, time in seconds for cache purge lock. Default: 10
  • SWCFPC_PURGE_CACHE_CRON_INTERVAL, time interval in seconds for the purge cache cronjob. Default: 10
  • SWCFPC_HOME_PAGE_SHOWS_POSTS, if the front page a.k.a. the home page of the website showing latest posts. Default: true (bool)

What hooks can I use?

Actions:

  • swcfpc_purge_all, no arguments. Fired when whole caches are purged.
  • swcfpc_purge_urls, 1 argument: $urls. Fired when caches for specific URLs are purged.
  • swcfpc_cf_purge_whole_cache_before, no arguments. Fired before purge the Cloudflare whole cache.
  • swcfpc_cf_purge_whole_cache_after, no arguments. Fired after the Cloudflare whole cache is purged.
  • swcfpc_cf_purge_cache_by_urls_before, 1 argument: $urls. no arguments. Fired before purge the Cloudflare cache for specific URLs only.
  • swcfpc_cf_purge_cache_by_urls_after, 1 argument: $urls. no arguments. Fired after the Cloudflare cache for specific URLs only is purged.

Filters:

  • swcfpc_bypass_cache_metabox_post_types, $allowed_post_types (Array). You can use this filter to ensure that the bypass cache metabox is also shown for your own custom post types. Example code link: https://wordpress.org/support/topic/disable-page-caching-for-specific-pages-with-cpt/#post-16824221
  • swcfpc_fc_modify_current_url, $current_uri (string). You can use this filter to modify the url that will be used by the fallback cache. For example you can remove many query strings from the url. Please note that this filter will return the URL without the trailing slash.
  • swcfpc_cache_bypass, one arguments. Return true to bypass the cache.
  • swcfpc_post_related_url_init, $listofurls (array), $postId. Fired when creating the initial array that holds the list of related urls to be purged when a post is updated. Show return array of full URLs (e.g. https://example.com/some-example/) that you want to include in the related purge list.
  • swcfpc_normal_fallback_cache_html, [One Arguments] : $html. This filter is fired before storing the page HTML to fallback cache. So, this gives you the ability to make changes to the HTML that gets saved within the fallback cache. This filter is fired when the fallback cache is generated normally via the advanced-cache.php file.
  • swcfpc_curl_fallback_cache_html, [One Arguments] : $html. This filter is fired before storing the page HTML to fallback cache. So, this gives you the ability to make changes to the HTML that gets saved within the fallback cache. This filter is fired when the fallback cache is generated normally via cURL method.

Can I use my own worker code along with the default worker code this plugin uses?

Unfortunately, Cloudflare allows one worker per route. So, as long as our worker is setup in the main route, you cannot use your own worker code in the same route. But you can take advantage of SWCFPC_CF_WOKER_FULL_PATH PHP constant to provide the full path of your own custom JavaScript file.

In this way you can take a look at inside the plugin's /assets/js/worker_template.js path and see the Worker code we are using by default. Then you can copy that worker template file in your computer and extend it to add more features and conditionality that you might need in your project. Once you are done with your Worker code, you can simply point your custom Worker template JavaScript file inside wp-config.php using the SWCFPC_CF_WOKER_FULL_PATH PHP constant and the plugin will use your Worker file to create the worker in your website route instead of using the default Worker code. Here is an example of how to use the PHP constant inside your wp-config.php. Please make sure you provide the absolute path of your custom Worker file.

define('SWCFPC_CF_WOKER_FULL_PATH', '/home/some-site/public/wp-content/themes/your-theme/assets/js/my-custom-cf-worker.js');

Please note that for 99.999% of users the default Worker code will work perfectly if they choose to use the Worker mode over the Page Rule mode. This option will be provided only for Super Advanced Knowledgeable Users who know exactly what they are doing and which will lead to what. General users should avoid tinkering with the Worker Code as this might break your website if you don't know what you are doing.

Can I purge the cache programmatically?

Yes. To purge the whole cache use the following PHP command:

do_action("swcfpc_purge_cache");

To purge the cache for a subset of URLs use the following PHP command:

do_action("swcfpc_purge_cache", array("https://example.com/some-page/", "https://example.com/other-page/"));

Best Wordpress Hosting

Best wordpress hosting providers tested by me

Our Products

Extend your website perfomance with more free products from our portofolio:

Optimole plugin

  • Cloud based image optimization service
  • Smart Lazyload ( background images included )
  • Auto Scaled Images
  • Machine Learning(ML) compression.
  • Automatically convert to best format(WebP, AVIF)
  • Deliver via CDN - AWS CloudFront ( 300+ locations )
  • Unmetered Bandwidth
  • Dozens of compatibilities with 3rd party plugins
Install

Neve theme

  • Lightweight, 25kB in page-weight
  • Perfomance built-in
  • Ready to use Starter Sites available
  • AMP/Mobile ready.
  • Dozens of ecommerce extra features
  • Lots of customizations options
View more