How long does it take for caching to be acitve?

caching

#1

Hello,

I added my website funfun.org.cn to CloudFlare 1 hour ago. The caching level is “Standard” and The development mode is “Disabled”.

But opening the website in Google Chrome or loading a file by curl (time curl -svo /dev/null http://www.funfun.org.cn/javascripts/others.js) does not show anything in response header about CloudFlare.

Does anyone know how long it takes for CloudFlare to be active? Should I check something in the setting?

Cheers

Tie


#2

Cloudflare cashes not immediately. Especially on free plans it could take some time (days) for new content to be cached.
And the items must be accessed “frequently”. Also by default static HTML will not be cached. You need a page rule to do this.


#3

Thank you.

What do you mean by

the items must be accessed “frequently”

?


#4

Content that is not accessed often enough gets deleted from the edges.


#5

Perfect. This setting restrict Cloudflare from caching only static elements such as CSS, JS, Images, etc.

Web Tools : HTTP / HTTPS Header Check
HTTP/1.1 200 OK => 
Server => nginx/1.10.3 (Ubuntu)
Date => Sun, 10 Jun 2018 10:33:25 GMT
Content-Type => application/javascript
Content-Length => 1824
Connection => close
X-Powered-By => Express
Accept-Ranges => bytes
Cache-Control => public, max-age=0
Last-Modified => Sun, 15 Apr 2018 15:19:56 GMT
ETag => W/"720-162c9e42a43"
set-cookie => connect.sid=s%3A-4HHHyam6eW47m6lDP4VnYRBGJV1BSTo.RPJiKaea20AB53qCibGiFIw3speH2kVIiNxYXrYDDw0; Path=/; HttpOnly

It appears your origin server is instructing do no cache with max-age value 0. In this case, Cloudflare will not cache if there is settings to respect existing origin header. But you may want Cloudflare to do cache for your static files, in order of resolve this issue

  • Login to Cloudflare > Select domain > Cache > Override the Browser cache time period from Respect existing header to 1 week at least.

Try this!


#6

Thank you.

The value of that option was not “Respect existing header”, it was “4 hours”. I just changed it to “8 days”. But it seems that the “Cache-Control” is still “public, max-age=0”.


#7

TLDR: In last test, sorry I forget to check one thing. What I found Cloudflare Proxy is not active currently at your site, that’s why you don’t see cache value to be reflected. And, by default 4 hours is what Cloudflare set but you should override it to a week.

I did check once again, and I found something interesting.

  • You are using Cloudflare Nameservers: https://dnschecker.org/#NS/funfun.org.cn
    :white_check_mark: Good

  • At your domain, Cloudflare Reverse Proxy is not active. You are using just DNS.
    :warning: Not cool. This is why you are facing problem.

To fix the issue, go to Cloudflare >select domain > DNS > Make sure DNS entries for root domain and www the Cloudflare should be enabled with Orange color (instead of grey)

Try this, it will fix the problem.


#8

Thank you, I just changed that icon from grey to orange.

And now, I can see “Server: cloudflare” in the response header. But it seems that all the static JS files have “CF-Cache-Status:MISS”.

Do you know why?


#9

Could anyone help?


#10

Your origin is telling Cloudflare not to cache the asset.


#11

If the Cache-Control header is set to “private”, “no-store”, “no-cache”, or “max-age=0”, or if there is a cookie in the response, then Cloudflare will not cache the resource.
Otherwise, if the Cache-Control header is set to “public” and the “max-age” is greater than 0, or if the Expires headers are set any time in the future, we will cache the resource.
Note: As per RFC rules, “Cache-Control: max-age” trumps “Expires” headers. If we see both and they do not agree, max-age wins.


#12

Could you give a screenshot that has “Cache-Control => public, max-age=0”?

I call my website from the US, as my above screenshot shown, I don’t see “max-age=0”, I have for example “Cache-Control:public, max-age=691200” in the response header.

But I do see “Cache-Control:no-cache” in my request header. How could I modify this?

Thank you


#13

It is in the response from your origin to Cloudflare.

curl -I --resolve www.your.domain:80:your.ip.addess http://www.your.domain/javascripts/others.js

HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Mon, 11 Jun 2018 16:56:20 GMT
Content-Type: application/javascript
Content-Length: 1824
Connection: keep-alive
X-Powered-By: Express
Accept-Ranges: bytes
Cache-Control: public, max-age=0
Last-Modified: Sun, 15 Apr 2018 15:19:56 GMT
ETag: W/“720-162c9e42a43”


#14

This topic was automatically closed after 14 days. New replies are no longer allowed.