CF stores in its cache my static files for only 1 hour, but I need more

I try to cache my static files for a long time, but in any case I get requests to my web server for static files. About 1 hour will pass until I see a line in my access.log file with the same file. I would like to store static files in CF Cache for 5 days. What am I doing wrong?

My settings:
Caching
Caching Level: Ignore query string
Browser Cache Expiration: Respect Existing Headers
Development Mode: Off

Page Rules
Match URL: http://mywebsite.com/wp-content/uploads/* (I copied it from my access.log)
Browser Cache TTL: 5 days
Cache Level: Cache Everything
Edge Cache TTL: 5 days

My headers:
For a lot of files:
HTTP/1.1 200 OK
Date: Wed, 13 Nov 2019 19:30:50 GMT
Content-Type: image/png
Content-Length: 250504
Connection: keep-alive
Last-Modified: Wed, 31 Jul 2019 11:15:08 GMT
ETag: β€œ5d41783c-3d288”
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: public, max-age=432000
CF-Cache-Status: HIT
Age: 1268
Accept-Ranges: bytes
Vary: Accept-Encoding
Server: cloudflare
CF-RAY: something

For new files or sometimes
HTTP/1.1 200 OK
Date: Wed, 13 Nov 2019 19:09:42 GMT
Content-Type: image/png
Content-Length: 250504
Connection: keep-alive
Last-Modified: Wed, 31 Jul 2019 11:15:08 GMT
ETag: β€œ5d41783c-3d288”
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: public, max-age=432000
CF-Cache-Status: MISS
Accept-Ranges: bytes
Vary: Accept-Encoding
Server: cloudflare
CF-RAY: something

When I don’t use CF proxy:
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 13 Nov 2019 19:23:30 GMT
Content-Type: image/png
Content-Length: 250504
Last-Modified: Wed, 31 Jul 2019 11:15:08 GMT
Connection: keep-alive
ETag: β€œ5d41783c-3d288”
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: public, max-age=315360000
Accept-Ranges: bytes

I see requests to my server like this:
HTTP/1.1
Host: mywebsite.com
Connection: Keep-Alive
Accept-Encoding: gzip
CF-IPCountry: RU
X-Forwarded-For: some IP
CF-RAY: something

for files which have to be cached.

I found a few topics with the same problem but without any helpful answer. What I need to do for longer storing my static files in CF cache?

Caching on Cloudflare is per datacenter, so if you have 5 requests for an image where

  • 2 requests came from visitors in London, then the 2nd request would be cached in CF London datacenter
  • 1 request came from visitor in Sydney, then 1st request would be non-cached miss if no other traffic came before it
  • 1 request came from visitor in Los Angeles, then 1st request would be non-cached miss if no other traffic came before it
  • 1 request came from visitor in Moscow, then 1st request would be non-cached miss if no other traffic came before it

Now if a 6th request came in from visitor in Sydney, then that would be a 2nd request from CF Sydney datacenters and would be a cache hit if within your cache storage time TTL.

1 Like

Is it mean that an image can be downloaded from my server 194 times (count of CF datacenters)?

So, will try to check it and change access.log format to saving CF-RAY response header.

Thanks for your answer.

yeah 194+ times so yes use CF-RAY id to differentiate which datacenter the request is coming from