Not caching text/html, static files cache fine

It seems CF is not caching text/html on https://dcciinfo.ae/, static files cache fine.

response headers for the homepage is below.

cache-control public, max-age=86400
cf-cache-status EXPIRED
cf-ray 617985088f393250-FRA
cf-request-id 07dfd1795100003250ce90e000000001
content-encoding br
content-type text/html; charset=UTF-8
date Tue, 26 Jan 2021 10:23:39 GMT
expect-ct max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct
expires Wed, 27 Jan 2021 10:23:28 GMT
nel {“report_to”:“cf-nel”,“max_age”:604800}
pragma cache
report-to {“group”:“cf-nel”,“max_age”:604800,“endpoints”:[{“url”:“https://a.nel.cloudflare.com/report?s=x4o67pdC6ooZ3QBwlxMamqc7HboVrb4e01ZgBl%2FaH3BMwhkhmLVwdta2qZBroVd8y4wL8QBO7fyYQypJn93FxSH4bilcJzP%2BKQVpow%3D%3D”}]}
server cloudflare
vary Accept-Encoding
X-Firefox-Spdy h2

It says cf-cache-status EXPIRED. However, I already set cache-control public, max-age=86400, expires Wed, 27 Jan 2021 10:23:28 GMT, and pragma cache

I added below Page Rule

https://dcciinfo.ae/* Cache Level: Cache Everything, Edge Cache TTL: 4 hours, Origin Cache Control: On

From the server, I removed any cookies, response headers confirm it.

I tried with https://cf-cache-status.net, strangely the 1st visit shows Error/Miss, subsequent visits show a Hit. However, http response headers still show cf-cache-status EXPIRED

A curl with curl -svo /dev/null https://dcciinfo.ae also confirms that cf cache status is Expired

https://gf.dev/ttfb-test shows TTFB high for Bangalore at 0.673

I wish to cache all urls and improve performance, any help is appreciated, thanks!

Do you ever see a HIT? That’s what shows for me:

No, I never see a HIT in devtools. It’s always expired. I cleared cache, hard reloaded, tried on both Firefox and Chrome.

However, when I put in your curl command, I did get a HIT. But when I curl with the url without the trailing / like this curl -I https://dcciinfo.ae it gives me EXPIRED

So, is it actually getting a HIT? and why is there a discrepancy with the cf-cache-status?

And also, ttfb from https://gf.dev/ fluctuates by a lot, yesterday New York showed around 0.2, now both New York and Bangalore shows 0.6+. So if it is cached on CF edges, why is the TTFB so high?

Thanks a lot!

Check these documentations.

By default, Cloudflare respects the origin web server’s cache headers in the following manner unless overridden via an [ **Edge Cache TTL** ](https://support.cloudflare.com/hc/articles/218411427#summary-of-page-rules-settings) Page Rule:
EXPIRED

The resource was found in cache but has since expired and was served from the origin web server.

I can see HIT in you first request.

3 Likes

Hi there,

I have tested using cURL on my end and I was not able to replicate the issue consistently as in the first time I observed a cf-cache-status: EXPIRED but all subsequent requests were cf-cache-status: HIT. Are you able to consistently replicate this on your end? I tested against this URL - https://dcciinfo.ae

Can you change your page rule to this and see if that makes any difference for you.

https://dcciinfo.ae*

Let me know if I can be of any further assistance here and I’ll be glad to help.

Rui

1 Like

Hi,

Thanks for the response.

Yes, I had gone through those docs before posting :slight_smile:

Yes, the 1st request shows a HIT, the url is with a trailing /. However, in the browser, it gets redirected to the url without the trailing / and it shows EXPIRED
My 3rd request is the same url without ending / and it shows EXPIRED.
Similarly, all other pages on the domain show MISS first, then when I hard reload, it shows EXPIRED

I changed to https://dcciinfo.ae* but it didn’t help.

But I set Origin Cache Control: Off in the Page Rule and it worked! After a couple of refreshes, it all shows HIT now, thanks to all of you!

I thought Origin Cache Control would be respected with that setting on, and the max-age and Expiry date are all in the future; and I also thought Edge Cache would override it.

Even then, I had switched off Origin Cache Control earlier, perhaps there was some other setting/rule overriding it earlier.

Thanks so much.

1 Like

On further testing, I found something interesting.

  1. Enabled Litespeed Cache on the server
  2. Used keycdn to check TTFB

Most locations show a small TTFB, and cf-cache-status shows a HIT, so it is having a direct impact. E.g. Frankfurt below shows TTFB as a minuscule 24ms (much joy :smiley:). Note it does not show Litespeed cache in the headers

On checking a location with a high TTFB, such as Singapore, cf-cache-status shows EXPIRED, and Litespeed shows a HIT, so it went to origin

Is this discrepancy due to a lag in caching the files to the edges? Perhaps I will check after a few hours and report back.

Also, many pages still show EXPIRED or even MISS (Customs Broker Dubai (1390+ verified listings)), so it is quite inconsistent.

The page Customs Broker Dubai (1390+ verified listings) now shows a HIT.
As long as most pages show a HIT, I’m OK with that.

Thanks a lot.

No worries glad you managed to get it to work. I will go ahead and resolve this thread but please let us know if you need any further assistance and we’ll be glad to help.

Have a nice day!

Rui

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.