Cloudflare Refuse to Cache my Files

When I check the header, it says

cf-cache-status: BYPASS

The only time, it will get cached is if create a page Rule

  1. Cache Everything
  2. Edge Cache TTL
  3. Origin Cache Control

All 3 rules need to active, otherwise, cloudflare won’t cache my files. Whether it’s a page, or static files such as css / js / image.

Any way to find out what’s the problem ?

I am using Wordpres with WP Fastest Cache.

The URL in Question is : https://smpmuh4delanggu.com/

It cached for me.

At the moment I am using this page rule. And it’s cached.

I just deleted the page rules. Normally the main page should show cf-status : dynamic and should cache the rest of the static content (css, and js).

I have purge the cache from cloudflare, but for some reason, now it’s showing still cached. This is weird.

date: Tue, 07 Jan 2020 14:43:20 GMT
content-type: text/html; charset=UTF-8
set-cookie: __cfduid=d3479684dfc4810d23e301cce27c71aa01578408200; expires=Thu, 06-Feb-20 14:43:20 GMT; path=/; domain=.smpmuh4delanggu.com; HttpOnly; SameSite=Lax
vary: Accept-Encoding
cache-control: max-age=16070400
cf-cache-status: HIT
age: 6865
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 5516b4152f99dd12-SIN

The cache shouldn’t exists, because it has been purged. Also it shouldn’t be cached in the first place. Because I have removed the page rules.

WP Fastest Cache might be setting that Cache-Control header. In the absence of page rules, Cloudflare will favor that.

It does look like it’s been in Cloudflare’s cache for a while (about 2 hours), so if you had just purged the cache, it might not have taken effect yet. Page rule updates and cache purges aren’t instant.

It’s back to normal for me. Cache-status is DYNAMIC, so that’s Cloudflare’s default behavior for HTML. I see no cache setting headers.
Screen Shot 2020-01-07 at 7.28.48 AM

Yes, after waiting for a while it finally backs to dynamic. Now back to my original question, doesn’t static content such as css/js/images cached by default by cloudflare ?

[email protected]:~# curl -I http://smpmuh4delanggu.com/wp-content/themes/unbk/css/bootstrap.min.css
HTTP/1.1 200 OK
Date: Tue, 07 Jan 2020 15:43:01 GMT
Content-Type: text/css
Last-Modified: Tue, 07 Jan 2020 09:57:37 GMT
Cache-Control: max-age=10368000
Expires: max-age=A10368000, public
Vary: Accept-Encoding
CF-Cache-Status: DYNAMIC
Server: cloudflare
CF-RAY: 55170b7f0d36d39a-LAX
Connection: Keep-Alive
Set-Cookie: __cfduid=d74d9248c673ae1cc7a8954964eb596f21578411780; expires=Thu, 06-Feb-20 15:43:00 GMT; path=/; domain=.smpmuh4delanggu.com; HttpOnly; SameSite=Lax
Set-Cookie: route=2352e8ba5d6994d958df218f93412c71; Path=/
Set-Cookie: SRVGROUP=common; path=/

it says dynamic, doesn’t the css file should be hit (or miss) ?

Yes, Cloudflare caches static files by default. Unless your server sends a no-cache type header. Can you post the URL of something that’s not working?

Okay, now I am super confused.

I literally just repeat the same command, yet it yield different results.

[email protected]:~# curl -I http://smpmuh4delanggu.com/wp-content/themes/unbk/css/bootstrap.min.css
HTTP/1.1 200 OK
Date: Tue, 07 Jan 2020 15:43:01 GMT
Content-Type: text/css
Last-Modified: Tue, 07 Jan 2020 09:57:37 GMT
Cache-Control: max-age=10368000
Expires: max-age=A10368000, public
Vary: Accept-Encoding
CF-Cache-Status: DYNAMIC
Server: cloudflare
CF-RAY: 55170b7f0d36d39a-LAX
Connection: Keep-Alive
Set-Cookie: __cfduid=d74d9248c673ae1cc7a8954964eb596f21578411780; expires=Thu, 06-Feb-20 15:43:00 GMT; path=/; domain=.smpmuh4delanggu.com; HttpOnly; SameSite=Lax
Set-Cookie: route=2352e8ba5d6994d958df218f93412c71; Path=/
Set-Cookie: SRVGROUP=common; path=/

[email protected]:~# curl -I http://smpmuh4delanggu.com/wp-content/themes/unbk/css/bootstrap.min.css
HTTP/1.1 200 OK
Date: Tue, 07 Jan 2020 15:47:01 GMT
Content-Type: text/css
Last-Modified: Tue, 07 Jan 2020 09:57:37 GMT
Cache-Control: max-age=16070400
Expires: max-age=A10368000, public
Vary: Accept-Encoding
CF-Cache-Status: HIT
Age: 3061
Server: cloudflare
CF-RAY: 55171160caf7e4dd-LAX
Connection: Keep-Alive
Set-Cookie: __cfduid=d45e4091a05a8a30aed77fedc7a13929b1578412021; expires=Thu, 06-Feb-20 15:47:01 GMT; path=/; domain=.smpmuh4delanggu.com; HttpOnly; SameSite=Lax

I am not doing anything, and now my website behaves perfectly what it supposed to do (caching static content).

Edit :
it now becomes BYPASS

[email protected]:~# curl -I http://smpmuh4delanggu.com/wp-content/themes/unbk/css/bootstrap.min.css
HTTP/1.1 200 OK
Date: Tue, 07 Jan 2020 15:55:52 GMT
Content-Type: text/css
Last-Modified: Tue, 07 Jan 2020 09:57:37 GMT
Cache-Control: max-age=10368000
Expires: max-age=A10368000, public
Vary: Accept-Encoding
CF-Cache-Status: BYPASS
Server: cloudflare
CF-RAY: 55171e568a9de829-LAX
Connection: Keep-Alive
Set-Cookie: __cfduid=dedd7854dbbfe91d3970c5ef7bff4a12e1578412552; expires=Thu, 06-Feb-20 15:55:52 GMT; path=/; domain=.smpmuh4delanggu.com; HttpOnly; SameSite=Lax
Set-Cookie: route=d9d722642a6837cabe5c8455c6315d86; Path=/
Set-Cookie: SRVGROUP=common; path=/

I literally don’t change any settings. Just refreshing the page over and over again.
Anyone can explain why it is so unpredictable ?

I am testing using the css file

http://smpmuh4delanggu.com/wp-content/themes/unbk/css/bootstrap.min.css

That Expires header looks wrong. It should be a date. From the spec:

Invalid dates, like the value 0, represent a date in the past and mean that the resource is already expired.

It’s auto generated by the wpfastest cache. At first I though it was the case, and proceed deleting it. But the status won’t change. It still bypass.

That may be part of their Browser Cache setting. I believe I usually have that disabled in WPFC. I don’t currently use that plugin, as I’ve moved to server-level caching.

Do you have any idea what caused cloudflare to Refuse cache some static files ?

I Found another thing.

When I am not using cloudflare (Grey DNS Only), my file load just fine and fast.

But when I activate cloudflare on my domain (Orange DNS), the same file (jquery.min.js), it took 16000MS. Imagine how long does it take to load the website, when it has to load several css/js.

When I ping my websites (it points to cloudflare ip), there are a lot of timeout.

I am from Indonesia, and my connection is fine. I can ping my servers without timing out.