CloudFlare Not using headers

Hello, I’m sorry but I’m from Brazil, I’m using google translator to ask for help, I hope understand!

Well, I have the following code

$seconds_to_cache = 60 * 1;//duration of the cache sent to the browser
$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . ' GMT';

header('Expires: ' . $ts);
header('Pragma: cache');
header('Cache-Control: s-maxage=' . $seconds_to_cache . ', max-age=' . $seconds_to_cache);

if I use .PNG at the end of the URL, it works perfectly, but if I do not use it, it does not save in the cache

Links examples:

I thank you all!

See
https://support.cloudflare.com/hc/en-us/articles/200172516-Which-file-extensions-does-Cloudflare-cache-for-static-content-

Cloudflare does not use MIME type or anything like that to determine cache, only the extension in the URL (as you’ve already discovered).

In order to get the cache working without .png at the end of the URL, you would need to set up a page rule with the action “cache everything”.

PS. Since max-age and s-max-age are the same value, you don’t really need to include s-max-age. it will respect the regular max-age header.

5 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.