Cf-cache-status: MISS

caching

#1

Hi, I am new to Cloudflare. I set up my domain in Cloudflare yesterday, and I could see my domain bsafes.com is active on Cloudflare.

However, I would like to know if scripts are cached in Cloudflare CDN or not. I used WebPagetest.org to test a files. I tried several times, unfortunately, it always showed cf-cache-status: MISS.

Could someone please help look into my situation? I would appreciate a lot.
Here is my test result -

Response Headers:

status: 200

cf-cache-status: MISS
x-powered-by: Express
vary: Accept-Encoding
server: cloudflare
last-modified: Fri, 21 Sep 2018 09:10:27 GMT
etag: W/“464-165fb6507b8”
cache-control: public, max-age=14400


#2

Here is the details

- Request 1: https://www.bsafes.com/javascripts/index.js

URL: https://www.bsafes.com/javascripts/index.js
Host: www.bsafes.com
IP: 104.18.43.254
Error/Status Code: 200
Priority: HIGHEST
Protocol: HTTP/2
HTTP/2 Stream: 1, weight 256, depends on 0, EXCLUSIVE
Client Port: 48700
Request Start: 0.155 s
Initial Connection: 34 ms
Time to First Byte: 60 ms
Content Download: 5 ms
Bytes In (downloaded): 0.9 KB
Uncompressed Size: 1.1 KB
Bytes Out (uploaded): 0.4 KB

Request Headers:

:path: /javascripts/index.js
accept-language: en-US,en;q=0.9
accept-encoding: gzip, deflate, br
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 PTST/180920.120941
:scheme: https
upgrade-insecure-requests: 1
:method: GET
:authority: www.bsafes.com

Response Headers:

status: 200
expect-ct: max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct
expires: Fri, 21 Sep 2018 19:06:25 GMT
content-encoding: br
set-cookie: __cfduid=dde5c48e01e234c7bb62e59702ec19ad01537542385; expires=Sat, 21-Sep-19 15:06:25 GMT; path=/; domain=.bsafes.com; HttpOnly
cf-cache-status: MISS
x-powered-by: Express
vary: Accept-Encoding
server: cloudflare
last-modified: Fri, 21 Sep 2018 09:10:27 GMT
etag: W/“464-165fb6507b8”
cache-control: public, max-age=14400
date: Fri, 21 Sep 2018 15:06:25 GMT
cf-ray: 45dd6f832c14c1cc-IAD
content-type: application/javascript


#4

It looks good to me, but I can confirm that I’m only getting MISS for that resource.

It’s possible there’s a header your server is sending that’s telling Cloudflare to not cache that resource.

Can you try:
curl -svo /dev/null --header “Host: example.comhttp://123.123.123.123/ javascripts/index.js (but use your server’s actual IP address).

You might have to resort to:
curl -svo /dev/null --resolve example.com:80:123.123.123.123 http://example.com/ javascripts/index.js

And then post that header. It’s ok to delete the actual IP address when you post the header.


#5

Hi, sdayman:
Many thanks for your message! Indeed, I tried to test several of my website’s resource, they were all MISS for cf-cache-status.

I followed your instructions, here is the result for your first suggestion. I appreciated your assistance!

curl -k -svo /dev/null --header “Host:bsafes.com” https:///javascripts/index.js

  • Trying xx.xx.xx.xx…

  • Connected to (xx.xx.xx.xx) port 443 (#0)

  • TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

  • Server certificate: *.bsafes.com

  • Server certificate: Amazon

  • Server certificate: Amazon Root CA 1

  • Server certificate: Starfield Services Root Certificate Authority - G2

GET /javascripts/index.js HTTP/1.1

Host:bsafes.com

User-Agent: curl/7.43.0

Accept: /

< HTTP/1.1 200 OK

< Date: Sat, 22 Sep 2018 02:00:35 GMT

< Content-Type: application/javascript

< Content-Length: 1124

< Connection: keep-alive

< Server: nginx/1.12.1

< X-Powered-By: Express

< Accept-Ranges: bytes

< Cache-Control: public, max-age=0

< Last-Modified: Fri, 21 Sep 2018 09:10:27 GMT

< ETag: W/“464-165fb6507b8”

< set-cookie: connect.sid=s%3Aa6a86c1b-d6bd-4f17-bc36-58a3884f0544.ztxMrv96fVKoXv9AZuhoNfnJf0uzg9N1%2FFTMbyW7o7o; Path=/; Expires=Mon, 23 Sep 2019 02:00:35 GMT; HttpOnly

<

{ [1124 bytes data]

  • Connection #0 to host left intact

#6

Cache-Control: public, max-age=0

This is probably what’s causing the MISS.


#7

Hi, sdayman:
Here is my result for your second suggestion, it showed HIT for cf-cache-status. But why was the response “HTTP/1.1 404 Not Found”


curl -svo /dev/null --resolve bsafes.com:80:xx.xx.xx.xx https://www.bsafes.com/javascrips/index.js

  • Added bsafes.com:80:xx.xx.xx.xx to DNS cache

  • Trying xx.xx.xx.xx…

  • Connected to www.bsafes.com (xx.xx.xx.xx) port 443 (#0)

  • TLS 1.2 connection using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256

  • Server certificate: sni.cloudflaressl.com

  • Server certificate: CloudFlare Inc ECC CA-2

  • Server certificate: Baltimore CyberTrust Root

GET /javascrips/index.js HTTP/1.1

Host: www.bsafes.com

User-Agent: curl/7.43.0

Accept: /

< HTTP/1.1 404 Not Found

< Date: Sat, 22 Sep 2018 02:17:12 GMT

< Content-Type: text/html; charset=utf-8

< Transfer-Encoding: chunked

< Connection: keep-alive

< Set-Cookie: __cfduid=d0edc86b3dfe35c4687583dcbd1f8ec6a1537582632; expires=Sun, 22-Sep-19 02:17:12 GMT; path=/; domain=.bsafes.com; HttpOnly

< X-Powered-By: Express

< CF-Cache-Status: HIT

< Expires: Sat, 22 Sep 2018 06:17:12 GMT

< Cache-Control: public, max-age=14400

< Expect-CT: max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct

< Server: cloudflare

< CF-RAY: 45e1461f4b2999a3-LAX

<

{ [800 bytes data]


#8

Hi, sdayman:
I tried the previous command again,
curl -svo /dev/null https://www.bsafes.com/javascripts/index.js
, it was still a cache miss.

What is the difference between above command and the command you suggested,
curl -svo /dev/null --resolve bsafes.com:80:xx.xx.xx.xx https://www.bsafes.com/javascrips/index.js

I appreciated you help very much!


#9

Those were just a couple of recommended ways to use Curl. It looks like your first attempt got the information I was looking for: the Cache-Control header. Your server is telling Cloudflare it’s a max-age of 0, which makes Cloudflare not cache that resource.


#10

Check that the site’s .htaccess isn’t overriding Cloudflare’s caching.
Also try adding a page rule in Cloudflare that says “Cache everything”


#11

Hi, sdayman:
Many thanks for your findings, I would figure out how to fix it.

Best regards,
Shih-Chin Yang


#12

Hi, holtslander:
Many thanks for your suggestions. My server is written in Node.js with Express framework, and hosted in AWS.


#13

Hi, sdayman:
My server is running by node.js with express framework. After I used express-cache-controller to set maxAge to a non-zero value, I started to see HIT in cf-cache-status for my requests.

Many thanks for your assistance in figuring out the issue.
Best regards,

Shih-Chin