CloudFlare Not using headers

#1

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:
https://skins.snowdev.com.br/skins3/5e873cde18e044cc86f7ea235a6ad500

I thank you all!

0 Likes

#2

See

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