I just noticed that some files (jpg, css, etc.) cached by Cloudflare on my website, show ’ cf-cache-status: HIT’ and have a response header AGE of less than 5000, usually between 0 and 1000.
As of the time of writing this, the AGE is ‘1102’. I want the edge-cached files to be cached for longer periods of time, not just 1 hour.
I currently have a server response of ‘cache-control: max-age=31536000’, but apparently, Cloudflare’s edge does not respect that and only caches files for less than an hour, I believe.
How can I extend the time that a file is cached on the edge, so users always have quick access to the .jpg, .css, etc files?"
Cloudflare by default will cache static files for the maximum duration set either by your Edge Cache TTL or whatever signal it gets from your origin. Cloudflare only caches content in the data center where the request comes from. And Cloudflare will evict from cache files that are unfrequently requested.
In summary, you cannot force Cloudflare to cache files for the duration you want, only signal to it the maximum duration you want.
Tiered Cache helps by making the cached page in datacenter A available to datacenter B (or C, D, …Z).
You should also consider a paid add-on feature called Cache Reserve, which will store the cache of your files in all Cloudflare datacenters, and respect the time you set in either Edge Cache TTL or Cache-Control header.