Css,JS not cached on CF edge

CF is not caching my css/js files

Caching Level: Standard
Browser Cache: Rexpect existing headers

Response headers on Js

Without a max-age, it makes me think it won’t be cached. Are images being cached?

Ok… thanks… Ill try to also set max-age. Yes images are cached by CF and they have a max-age, but no expires header.

CF docs are not entirely clear. As I read it, the expires header should be enough

  • If the Cache-Control header is set to private , no-store , no-cache , or max-age=0 , or if there is a cookie in the response, then Cloudflare does not cache the resource.
  • Otherwise, if Cache-Control is set to public and the max-age is greater than 0 , or if the Expires header is a date in the future, Cloudflare caches the resource.
  • If both max-age and an Expires header are set, max-age is used.

The more I look at caching, the more it looks like black magic.

How is it that the last-modified date is the exact same time as the request?

Can you post the domain name so we can poke around a bit? Something has to be stopping those resources from being cached. Cookies?

hmmm… that is a bit strange…

exactmeals.com is the website

It’s a mystery to me. Your images are set up nicely. They use max-age and are showing a HIT. JS and CSS are set up differently, and I don’t know why, nor why they don’t work with Expires set.

@floripare is pretty good with caching. Maybe he knows.

Ha! I wish I was! I’ve just publish about a week ago a website for which I wanted to set an expires header to make the front page change at every so many hours. Tried all tricks in the book, but never managed to do it.

As for the issue @martin38 is facing, I did some digging and found this:

Cloudflare only caches based on file extension

and your JS files seem to lack a .js extension.



Well, shoot. Thanks for pointing out the obvious that I completely missed. :flushed:

(css also has no file extension)


Thanks so much @sdayman and @floripare for all the help.
No extensions was exactly the problem.
Site was built with asp.net which uses a bundling feature for js and css. The bundles are held in a virtual folder in memory and no way to set a file extension (as they are not files.)
Anyway easy enough to add a page rule to workaround.


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