I have a page rule that is attempting to cache an aspx page.
The link(s) include a parameter that determines which content is downloaded:
The output of the page is a pdf with a cache-control header of public with a 1 year max-age.
Cache-Control: public, max-age=31536000
I can’t seem to get this to cache. Are there any tricks to figuring out why not? Any ideas on what else I might do?
Do you have any other Page Rules?
Yes. This particular rule 3rd in the priority and doesn’t seem to be something that would be affected by the two rules ahead of it.
Your seconds Rule should not work also because the First Rule already matches everything. Only one Page Rule per Match is executed and because the First one already matches everything the Rest should not be executed
The First Page Rule you have is also probably not needed. Do you really need the onlc.com to www.onlc.com redirect? If not there is a Setting under: SSL/TLS → Edge Certificates, to always use HTTPS. When you activate this Setting Cloudflare will automatically redirect http to https so you dont need a extra Page Rule for that. So the First Page Rule would only do non www to www. redirect
We probably don’t need the first rule since it’s handled by the web server anyway.
I disabled the first rule and was still getting dynamic cache status returned on the second and third rules though.
I then saw that, in some of the lower rules, I had used an * as the first character when specifying the rule. For example:
The rules with the * seemed to work - e.g. I was getting HIT on the cache status.
So I put a * as the first character in for the third rule and it, surprisingly, started to return HITs as well. I added the * on the 2nd rule and it began to return HIT for cache status as well.
And, just for grins, I turned the first rule back on and I’m still getting HITs returned on the 2nd and 3rd rules.
I don’t know how to explain why the * rules work though…
This could be because its cached now. Normally it should ignore those Rules now and use the Cloudflare Default Behaviour… Which for mp3 is cache and respect the max-age Header from the Webserver anyway
This could be Part of the non www to www redirect. Without * it just matches the exact Input. And www.onlc.com is different from onlc.com
I was thinking that rules without the * would match either www or the bare domain because the * isn’t needed to distinguish between http and https.
I’m not sure how I made that leap but thanks for helping me think through the situation.