Using wordpress caching plugin with cloudflare

It is recommended that wordpress sites use a caching plugin, but caching doesn’t work when I have CF activated. When I put CF in development mode, I get the green timestamps at the bottom of my html showing that wordpress is caching, but with CF on, the timestamps disappear, and this is confirmed with pingdom, et al, which give me an “F” for caching when Cloudflare is activated.

I’m currently using wpfastestcache, but the problems occurs with other caching plugins, so it isn’t the plugin per se. Does anyone have a suggestion what settings in the plugin, or in Cloudflare, or in htaccess, or elsewhere in the WP install might be causing this behavior?

Thank you in advance for any help with this.

I use WP Rocket; it comes with a dedicated tab for Cloudflare Integration.

It not free, but it helped me get rid of separate cache, optimization, and CDN plugins.

Thanks.I haven’t been able to get the free ones to work consistently, so I’m reluctant to pay for one knowing there may be other configuration issues at fault, and not necessarily the plugin itself. But I’ll consider it.

Hey there. I don’t run Wordpress anymore but I’ve had good success in the past with Wordpress on Cloudflare with the W3TotalCache plugin and also Autoptimize plugin (for asset minification).

I wrote this topic about setting up Wordpress on NGINX with those plugins - most of the info probably isn’t relevant but I do go over the settings I use for those plugins, so it might be helpful.

There also might be a better caching plugin out there now that I just don’t know about, though I always found W3TC to be perfectly capable & customizable for my needs.

Thanks. I’m on Apache, and had the same result with W3TC.

let me clarify my question:

  1. Is the green timestamp from my wordpress caching plugin supposed to be visible at the bottom of the html (page source) on Cloudflare served pages? Sometimes when I run site speed tests (pingdom, etc), there is an indication that some files are being cached. At other times, it seems like files aren’t being cached. However, at no time do I see the green timestamp at the bottom of the html.

  2. Are there any known plugin issues that could prevent caching in conjunction with Cloudflare?


Can you provide an screenshot which can clarify about which type cache you are talking -

  • Is it Browser cache?
  • Is it Page cache?


Would you be willing to provide your URL? If not that’s ok…

Yes it should be visible. View the source of this for a functional example. I’m not sure how you have your cache settings in the Cloudflare dashboard - you may have to purge the cache to force Cloudflare to retrieve an updated version.

You can check if an asset is being served via Cloudflare cache by opening up your inspector or dev tools in your browser, switching to the network tab, and viewing the response headers for an image, such as in this screenshot (you’re looking for Cf-Cache-Status: HIT)

Cloudflare’s stance appears to be ‘use at your own risk’ as noted in this article

Thank you for the information.
I think I’ve resolved the issue, at least for now. I’ll explain what I did in case it helps anyone else. Experiment and testing is difficult with Cloudflare, because it can take many hours before a change takes effect, even after clearing the cache.

In Cloudflare, I unchecked minification for for html and css, but kept it for js, and cleared the cache. In WPFC, I chose the html and css minification, and css combine options, but not the js minification options, saved the changes, cleared the cache, and deactivated the plugin. Then, I cleared everything from the site htaccess file except the wordpress code, and finally reactivated WPFC, and checked htaccess to be sure the cache code was written to the file. Then I tested intermittently (in a logged-out browser) over several hours, still with no change. I finally went to sleep. When I woke up and tested the site, the green timestamps were finally there. The site speed score is much improved in pingdom/gtmetrix/webpagetest/pagespeed insights.

The site could still be much faster, so I will experiment some more with different setting combination in WPFC and Cloudflare, but at least now I have an acceptable baseline I can resort to.

One thing I’ve noticed is that “first byte time” tends to be slow when Cloudflare is activated. CF tech support told me years ago that this is because speed tests “don’t understand reverse proxy.” Can anyone explain what that means, and why it would a site tester like would show 5-10 seconds for first byte time when CF is activated, and 10-14 sec load time, but only 0.248s first byte time, and 4-6 second load time when CF is in development mode?

Nice! Glad you got it sorted. Minification can be tricky, and if you’re minifying twice over it usually results in trouble so I’m not surprised if that was causing issues. Also if you’re looking for timestamp comments in your HTML, some minifiers could be stripping those comments.

As for your TTFB, hopefully someone else will chime in cause I’m not really sure why it would be significantly different. I’m sure you’ve repeated your tests from various locales, as usually the first test from a new location will not have assets cached at that Cloudflare edge location, so you will see cf-cache-status: miss for assets on the first test.

Thanks for tip on looking for Cf-Cache-Status to check on caching in the inspector.

I try to be careful to set just one minification for each file type. I had previously been using CF minification, so maybe that was stripping the timestamps?

Yes, I did run multiple tests from different locations for the TTFB.

Please Note: WP Rocket is NOT compatible with GoDaddy (Managed/Shared Hosting Plan). It may work for a few days, but suddenly your website will “break.” Confirmed with GoDaddy. Unfortunately, they have no plans to add this to their list of blacklisted plugins.

Fast Velocity Minify rocks. Give it a try. It’s a minification plugin that just works (compatible with many cache plugins - as noted by the plugin author). We’re not selling anything here, just sharing our experience after testing many cache and minification plugins.

Good point on GoDaddy, I had to stop hosting with them because they are too far behind (php versions, SQL versions etc, to support the newest plugins).

1 Like