Apologies, the profiles section was an example of the bits that are working, the issue is that the bundled references that are generated in asp.net do not have an extension so aren't caught and are being set as public cache-control which is causing them not to be cached by cloudflare. Extension based files are working fine
Hi Scott,
I may be missing something but, as far as I'm aware, if you want your content to be cached, you want cache control set to public, ideally with a max-age value set to > 0. If you need to change that header and the usual web.config options aren't working you can hook in to the Application_PreSendRequestHeaders event either in global.asax or in an httpmodule and modify the response headers in there.
One thing which I was made aware of recently is the following line from the CloudFlare docs:
"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 will not cache the resource."
I don't know whether this applies to your situation but, if the responses from the bundle requests return a cookie for any reason, they won't be cached, regardless of the headers set. If that's your issue you may need to get the cloudflare config tweaked or do something to strip out the cookies before sending the response.
Hope that helps.
One other thing which comes to mind - by default CloudFlare only caches content which it considers to be static and, as far as I'm aware, it does this by looking at the file extension. In your situation I don't see a file extension and so it may well be that CloudFlare is assuming it's dynamic and not caching it regardless of the headers set. If this is the issue (and you can't change the URLs to include a file extension) you'll need to get a page rule set up in CloudFlare to allow that content to be cached.
As Paul said. Add a file extension to the bundle name. We had and fixed the same problem this way.
How do I add a file extension when it's auto generated? This was actually my first thought to make the css bundle have .css and the js one to have .js but couldn't see how to change the name?
Jesus I've been an idiot, I was trying to sort this issue earlier on and I completely forgot our bundle paths are in constants.
Hey all,
We have asp.net standard bundling in our website which create paths for js/css such as
It was raised in some load tests that cloudflare is not caching these path like it would normal js/css based upon the standard caching profiles as below.
This looks to be as the cache-control header is set to public. Does anyone know how to get the bundling system to change this cache control header? I've followed some posts online but can't seem to get it working.
Thanks in advance