Cloudflare doesn't cache my website well

caching

#1

Hello, everyone!

Here is my website: [www.wecard.org.cn]
My cloud server is on Aliyun, which is located at Qingdao, Shandong Province, China.

But when I open my website, I find that most requests are not being cached.
Here is a picture show the analytics of my website.

When I open my website in Chrome, and I open the dev tools

I click every *.js file and I find that EVERY *.js file “cf-cache-status” shows a “MISS”, rather than a “HIT”

HERE ARE SOMETHING THAT I NOTICED:

  1. In the first picture, the number of Total Requests is 1472, and the number of Cached Requests is 99.
    So the ratio of cached requests and total requests is equal to 6.7%. Is this a normal rate? I think it’s a little bit small.

  2. Although In the analytics there are 99 Cached Requests, I couldn’t find which file had been cached, either any info related on the Cloudflare analytics.

  3. In the second picture, I notice that there is an argument “max-age=14400”, I just wonder if the max-age = 14400 is too small so that Cloudflare won’t cache my *.js file.

QUESTIONS:

I just can’t find the reason that why Cloudflare doesn’t cache my website.

Any help or suggestion is appreciated!

Thanks!


#3

Your origin server is telling Cloudflare not to cache the content.

HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Wed, 27 Jun 2018 05:55:11 GMT
Content-Type: image/png
Content-Length: 2864
Connection: keep-alive
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS
Accept-Ranges: bytes
Cache-Control: public, max-age=0
Last-Modified: Tue, 26 Jun 2018 21:12:29 GMT
ETag: W/“b30-1643df0ce48”

he second way to alter what Cloudflare will cache is through caching headers sent from the origin. Cloudflare will respect these settings, but you can also override them by specifying an Edge Cache TTL. Here are the caching headers we consider:

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.