HTTP response not cached with Cache-Control: public, max-age=86400

Why is the following HTTP response not being cached by Cloudflare? There are no Page Rules or other specific configuration in place.

HTTP/2 200
date: Tue, 24 Oct 2023 13:31:00 GMT
content-type: application/json
cache-control: public, max-age=86400
expires: Wed, 25 Oct 2023 13:31:00 GMT
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
last-modified: Tue, 24 Oct 2023 13:31:00 GMT
vary: Accept-Language
cf-cache-status: DYNAMIC
server: cloudflare
cf-ray: 81b293ddbb18a780-EZE

Any hint?

Content-type says json, so that’s probably not a cacheable URL:

Where in the that documentation states that JSON content is not cacheable per-se? The documentation states that if the response includes:

Cache-Control header with “public” and a “max-age” greater than 0, the response is cacheable.

Also, the Expires header is set to the future (24 hours).

Any insights on why the cf-cache-status is DYNAMIC?

If you scroll the documentation page down you will see that Cloudflare caches based on extension, and JSON is not listed there.

It means the file isn’t eligible to be cached.

You can change the behaviour by adding a page rule to cache it.

1 Like

Caching by “file” extension is one of the means Cloudflare uses to evaluate if a resource is cacheable or not. The other - that take precedence - is Cache-Control header sent by the origin server.

Any other opinion here?


With amazing timing, cache rules is now generally available from today.

1 Like

I know a custom Page Rule would serve as a hack to force the caching of anything. But we need to understand why Cloudflare is not respecting the Cache-Control public with max-age greater than 0 header as stated in the documentation. It should not be necessary to create Page Rules if the server response is correct.

Maybe the Vary header is bothering? Maybe the Last-Modified?

As stated in the documentation, JSON is not cached by default. The cache-control header is ignored for file extensions not in the list. The same applies to HTML, directory root requests and so on in case these contain dynamically produced data.

Use the new cache rules to force the caching you need.


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.