"Cache Level" -- "Cache Everything" Not Caching

In page rules I have set up

Also in Caching

in my .htaccess file I have
Header set Cache-Control “max-age=31536000, public”

If I test my page https://www.metrotrekker.com/australia-perth-top-hiking-and-walking-trails on webpagetest.org I get an F for Cache Static Content.

If I go to an image within the webpagetest.org details I get the following

- Request 6: https://www.metrotrekker.com/metro/australia/perth/images/_s/mundy_regional_park_perth_284_s.jpg

URL: https://www.metrotrekker.com/metro/australia/perth/images/_s/mundy_regional_park_perth_284_s.jpg
Host: www.metrotrekker.com
Error/Status Code: 200
Priority: MEDIUM
Protocol: HTTP/2
HTTP/2 Stream: 11, weight 220, depends on 3, EXCLUSIVE
Initiated By: https://www.metrotrekker.com/australia-perth-top-hiking-and-walking-trails line 432
Client Port: 48430
Request Start: 0.636 s
Time to First Byte: 160 ms
Content Download: 6 ms
Bytes In (downloaded): 3.3 KB
Uncompressed Size: 3.3 KB
Bytes Out (uploaded): 0.6 KB

Request Headers:

:path: /metro/australia/perth/images/_s/mundy_regional_park_perth_284_s.jpg
accept-language: en-US,en;q=0.9
accept-encoding: gzip, deflate, br
accept: image/webp,image/apng,image/,/*;q=0.8
user-agent: Mozilla/5.0 (Linux; Android 6.0.1; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.101 Mobile Safari/537.36 PTST/190704.170731
:scheme: https
referer: https://www.metrotrekker.com/australia-perth-top-hiking-and-walking-trails
:method: GET
cookie: __cfduid=d26c058392bdd58da1a9f09eb66e7530e1562654516
:authority: www.metrotrekker.com

Response Headers:

expect-ct: max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct
status: 200
content-length: 3374
cf-cache-status: MISS
expires: Tue, 09 Jul 2019 06:41:55 GMT
vary: Accept-Encoding
server: cloudflare
last-modified: Wed, 03 Oct 2018 18:42:17 GMT
cache-control: no-cache
date: Tue, 09 Jul 2019 06:41:56 GMT
cf-ray: 4f3850a9594dc1a2-IAD
content-type: image/jpeg
accept-ranges: bytes
:status: 200

That is, it isn’t cache. I have also used Chrome and Firefox developer and get the same result. No cache.

If I pause Cloudflare cache works.

I’m stuck and don’t know what to do. Please help.

That’s a problem. I see you set it to 31536000 in .htaccess, so I’m not sure where it’s getting changed.

You shouldn’t need the Cache Everything rule for static content. How about changing Browser Cache Expiration to an actual value instead of Respect Existing Headers?

Thanks for your response. I changed the Browser Cache Expiration to 1 day but I still have the same problem.

Can you try the following, but replace the 123 address with the IP address of your origin server?

curl -I --resolve www.metrotrekker.com:443: https://www.metrotrekker.com/metro/australia/perth/images/_s/mundy_regional_park_perth_284_s.jpg

(That’s a Curl dash capital i) And then post the results. Go ahead and anonymize your real IP address in the results.

Thanks again!

I did as suggested and this is what I get.

HTTP/1.1 200 OK
Date: Wed, 10 Jul 2019 00:06:40 GMT
Server: Apache
Last-Modified: Wed, 03 Oct 2018 18:42:17 GMT
Accept-Ranges: bytes
Content-Length: 3374
Cache-Control: max-age=31536000, public
Content-Type: image/jpeg

It is interesting that you suggested this. I had a problem with cloudflare back in April (my website did not show and instead got a cpanel page, /cgi-sys/defaultwebpage.cgi, suggesting “The IP address has changed.”, “There has been a server misconfiguration” or “The site may have moved to a different server.”). I investigated myself and found that the IP address quoted on cpanel was different to when I pinged it. I contacted my hosting provider and they suggested to pause cloudflare. It worked. Then recently I unpaused cloudflare, the website worked, but no cache. I asked them to help with the cache problem, but they said contact cloudflare.

The response to curl above is from the IP quoted on cpanel.

This is the response of the IP which I ping.

HTTP/1.1 200 OK
Date: Wed, 10 Jul 2019 00:10:42 GMT
Content-Type: image/jpeg
Content-Length: 3374
Connection: keep-alive
Set-Cookie: __cfduid=d1d41d07e0d69cb22e268a9c99723bda21562717441; expires=Thu, 09-Jul-20 00:10:41 GMT; path=/; domain=.metrotrekker.com; HttpOnly
Last-Modified: Wed, 03 Oct 2018 18:42:17 GMT
Cache-Control: no-cache
Expires: Wed, 10 Jul 2019 00:10:41 GMT
CF-Cache-Status: MISS
Accept-Ranges: bytes
Expect-CT: max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct
Server: cloudflare
CF-RAY: 4f3e50ebbd81a35a-HKG

Hope this helps. Really not sure what I am doing.

Something is definitely changing it in Cloudflare. No telling which setting is affecting this cache. It could be in the Caching tab, a Page Rule, or a Worker. Or some other unknown source. Open a Support Ticket. Maybe they can track down what’s changing it. Include a link to this thread.

Login to Cloudflare and then contact Cloudflare Support by clicking on the Get More Help button.

1 Like

Thank you very much for your help :smiley:

1 Like

Thanks @sdayman for your help. The problem is finally solved.
It all came down to my hosting provider installing Imunify360 web firewall system. I overcame the problem with some page rules.

Hope this helps anyone else with the same problem.
Best Regards,

1 Like

Wrong he have to add this Screenshot_1

I confess I’m completely unfamiliar with that feature, and the docs don’t clear it up for me. At face value, it sounds like it overrides the server’s decision on what should or should not be cached. The docs don’t clearly state “On means this will happen. Off means this will happen.”

Lol it is simple… and easy…

Origin Cache-Control = ON (Cloudflare check your server headers, if set cache public- servers will cache!, if not set, cloudflare servers do nothing to ur content about cache)

Origin Cache-Control = OFF (Cloudflare dont check your server headers about if set or not set. Servers will be forcing your content to cache)

Ok, so it sounds like ON means your server sets cache on or off. And if Cloudflare would normally cache the resource, then Cloudflare will cache it, unless your server tells Cloudflare not to.
And OFF means Cloudflare doesn’t care what your server says. If Cloudflare would normally cache it, it will. And if you tell Cloudflare “Cache Everything”, then it will.

Browser and Edge Cache TTLs also seem like they override your server’s Cache Control.

I’ll have to sit down some time to see how they all interact.

Thanks @olgarverim that did make a difference.

I was too focused on the cache of the images (the .js and .css also cached) that I didn’t even notice that the .php wasn’t.

I set the Origin Cache-Control = ON and now the .php caches as well. However, the response headers are different for everything.

For an image without the Origin Cache-Control I get “public, max-age=16070400”
For an image with Origin Cache-Control = ON I get “private, max-age=16070400”

The max-age is dependent on what I set for the Browser Cache.

Having “Header set Cache-Control “max-age=31536000, public”” in my .htacess seems to make no difference at all.

Anyway, my pages are loading way quicker now. Thanks for everyone’s help.