Website images are always MISS

Hi All,

I’ve new to cloudflare and i’ve moved 2 seperate websites to be behind cloudflare. They both have seperate domains and are powered by node/express web servers.

For some reason, the images in website 2 always have " cf-cache-status:MISS". I’ve run the diagnostic tool as well as looked at other forum posts and and done some testing but still can’t work out why the images are not getting cached.

"Website 1" works perfectly and caches the images correctly. These are it’s response headers:

accept-ranges: bytes
access-control-allow-origin: *
alternate-protocol: 443:npn-spdy/2
cache-control: public, max-age=31536
cf-cache-status: HIT
cf-ray: 5cbbbd467d7724bb-HKG
cf-request-id: 04e934a00f000024bbe128f200000001
content-length: 96991
content-type: image/jpeg
date: Tue, 01 Sep 2020 03:00:09 GMT
etag: W/"17adf-159948f85d8"
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
last-modified: Thu, 12 Jan 2017 21:22:31 GMT
server: cloudflare
status: 200
vary: Accept-Encoding
x-powered-by: Express

Website 1’s general headers are:

Request URL: https://wesbite1.com/thumbs/lrg/1439010507511.jpg
Request Method: GET
Status Code: 200  (from disk cache)
Remote Address: 111.11.11.111:443
Referrer Policy: no-referrer-when-downgrade

"Website 2" images always say MISS. Here are it’s headers.

accept-ranges: bytes
cache-control: public, max-age=14400
cf-cache-status: MISS
cf-ray: 5cbb2e9e0dcf32cd-HKG
cf-request-id: 04e8db76c8000032cdd22c3200000001
content-length: 194072
content-type: image/png
date: Tue, 01 Sep 2020 01:22:46 GMT
etag: W/"2f618-17442864d60"
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
last-modified: Mon, 31 Aug 2020 03:18:52 GMT
server: cloudflare
status: 304
vary: Accept-Encoding
x-powered-by: Express

Website 2’s general headers are:

Request URL: https://website2.com/dist/beaa8a53cb71d79d58f6cc0a1fcb0c4d.png
Request Method: GET
Status Code: 200  (from memory cache)
Remote Address: 111.11.111.111:443
Referrer Policy: no-referrer-when-downgrade

Can anyone help identify which headers in website 2 are making images to always MISS? or is there something else going on?

Test Links
Website 1 (this works fine): https://wisdomtoinspire.com/authors/albert-einstein

  • have the look at the images and it’s HIT

Website 2 (Images always MISS): https://itheum.com/

  • have the look at the images and it’s always MISS

Thanks in advance.

Please share actual URL in question. It’s impossible to answer without it. All sites are different. We can’t guess.

image

Sure. Thanks for the reply

Website 1 (this works fine): https://wisdomtoinspire.com/authors/albert-einstein

  • have the look at the images and it’s HIT

Website 2 (Images always MISS): https://itheum.com/

  • have the look at the images and it’s always MISS

It is actually not a MISS, rather an EXPIRED.

And that is because your server sends a cache control header with “max-age=0”, which tells Cloudflare to never cache. You will need to adjust this on your server.

I’m seeing MISS, then REVALIDATED. Maybe it has something to do with the etag:

[email protected] ~ % curl -I https://itheum.com/dist/beaa8a53cb71d79d58f6cc0a1fcb0c4d.png
HTTP/2 200 
date: Tue, 01 Sep 2020 17:59:30 GMT
content-type: image/png
content-length: 194072
set-cookie: __cfduid=d073fbddd0062362d147612c3972d52ad1598983170; expires=Thu, 01-Oct-20 17:59:30 GMT; path=/; domain=.itheum.com; HttpOnly; SameSite=Lax; Secure
x-powered-by: Express
cache-control: public, max-age=14400
last-modified: Mon, 31 Aug 2020 03:18:52 GMT
etag: W/"2f618-17442864d60"
cf-cache-status: REVALIDATED
accept-ranges: bytes
cf-request-id: 04ec6c01ca0000056481863200000001
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 5cc0e2afacea0564-LAX

I don’t have that URL at all in the HTML, but even that URL only returned EXPIRED.

Anyhow, the max-age value prevents Cloudflare from caching.

Thanks for having a look guys.

But all images from the domain https://itheum.com/ are showing MISS and the max-age is NOT 0 (it’s max-age=14400)

@sandro where did you see max-age=0?

I see a max-age, but no age. And I see an etag header. I think etag is interfering with Cloudflare’s caching.

Straight from your server

HTTP/1.1 200 OK
Server: nginx
Content-Type: image/jpeg
Content-Length: 41326
Connection: keep-alive
X-Powered-By: Express
Accept-Ranges: bytes
Cache-Control: public, max-age=0
Last-Modified: Mon, 31 Aug 2020 03:18:52 GMT
ETag: W/"a16e-17442864d60"
1 Like

I think your are right @sandro - the origin server is defaulting to the max-age=0 and cloudflare seems to be putting in it’s own max-age as seen in the browser screen shots. But it’s honouring the origin server’s max-age=0 and therefore not caching.

Let me fix the origin server’s max-age and see if that changes cloudflare downstream behaviour

At the risk of sounding cocky :wink: - I know :smile:

The cache control in your screenshot is the default Cloudflare sends to the browser, however Cloudflare still follows the server for its own cache.

If you fix the server header, I am pretty sure Cloudflare will start caching.

Pardon for my cockiness :blush:

:slight_smile: appreciate the quick responses and help (as well as the cockiness)

I’ll make the changes, test and update this post if (i.e when) it works!