March 13, 2023, 12:59pm
Hello everyone! I hope you’re all having a pleasant Monday! Although I’ve been a Cloudflare user since 2011, I haven’t been very active in these forums, so I apologize in advance if I’m posting this in the wrong area or otherwise. Let me know, and I’ll correct any issues with this post.
The issue I’m experiencing is probably due to some config issue
on my end. However, I require your help… I appreciate your patience.
Answer these questions to help the Community help you get started.
What is the domain name? https://haydenjames.io/
Have you searched for an answer?
Yes. and also the web. Please share your search results url:
We have a page rule for caching .json files. It was working fine but suddenly stopped working. There was no change in origin response headers. No other page rule matches the pattern.
I have attached screenshot of page rule (note: I have replaced my real domain name)
Here are origin response headers:
< HTTP/1.1 200 OK
< Server: nginx
< Date: Fri, 09 Jul 2021 04:34:46 GMT
< Content-Type: application/json
< Content-Length: 956
< Connection: keep-alive
< Vary: Accept-Encoding
When you tested your domain using the Cloudflare Diagnostic Center, what were the results?
I did search/find text on that page for that tool I’m honestly not sure where to find it.
I’ve been using browser inspect and curl as well to test:
Describe the issue you are having:
The following file won’t cache and is always marked “MISS”: https://haydenjames.io/site-webmanifest.json
What error message or number are you receiving?
What steps have you taken to resolve the issue?
Confirmed headers and mime type config in Nginx
disabled all caching plugins on Wordpress
purged Cloudflare cache
Was the site working with SSL prior to adding it to Cloudflare?
What are the steps to reproduce the error:
Have you tried from another browser and/or incognito mode?
Yes, and yes. (Chrome and Firefox)
APO will only cache HTML content. You can create a Cache Rule to cache your JSON file.
However, as I reloaded a few times the link to your file, I’ve seen the
cf-apo-via: header :returned with different values:
cf-apo-via: origin,no-cache >> the origin sends a response Cache-Control header with a no-cache or similar directive.
cf-apo-via: origin,resnok, >> the HTTP Status was not 200. (Instead, it was 304)
So you may want to check your origin for configurations that might result in these intermittent results.
For more detail on the APO headers returned, please see:
March 13, 2023, 1:56pm
@cbrandt, Thanks for the help.
I was not depending on APO to cache this file. Is this specific to JSON? Because css, js, and images are marked “HIT”. I was unaware that APO would influence the caching outside of HTML?
Sure, let me know if there are any config issues I need to look for on origin/Nginx. I have checked and .json is set the same as .js (as it relates to cache control and making sure the mime type is present). Anything else?
list of file extensions that Cloudflare considers “static files” and those are cached by default. Anything outside of this list needs a Cloudflare Rule (Page Rule or the newer Cache Rule (beta)) or some other product like APO.
Your origin is actually returning a cacheable Cache-Control directive, so I don’t know where APO gets the “no-cache” from.
Anyway, what you need to do is try a Cache Rule setting both browser and Edge cache to whatever time you with, see if that solves the problem.
March 13, 2023, 2:10pm
Ok, I understand now what you are saying now. Thank you. Will check.
Also, I noticed a cookie is added to that file from a popular plugin. I am checking as well.
I will try this. thanks
I was looking at the existing page rules:
Shouldn’t that rule apply to that file, also? Should I remove these since APO is being used?
March 28, 2023, 2:10pm
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.