Unable to cache json api with page rules - stays at: DYNAMIC

I am trying to cache an api get request that produces json - using cloudflare by page rules : Cache Everything with Edge Cache TTL > 0 .
No matter what I try - I am unable to get past: CF-Cache-Status: DYNAMIC !
Referring to the documentation of page rules I even tried a sample xml file - but the same issue persists.

Using cf workers too - availed no result. The api is being served by Spring Boot , have tried virtually all combination of headers. What am I doing wrong?

Could you send a screenshot of the page rule? :slightly_smiling_face:

1 Like

Hi @albert, same page rule works well for a static resource. I have spent many hours and hours :disappointed_relieved:.
Server uses self-signed certificate behind cloudflare’s ssl at port 8443.
Page rule is definitely matching the intended url - confirmed by error upon using SSL : strict

https://<domain>.com:8443/cache_*
Cache Level: Cache Everything

Here is the response header:

{
	"key": "Date",
	"value": "Wed, 03 Nov 2021 08:31:37 GMT",
}, {
	"key": "Content-Type",
	"value": "application/xml",
}, {
	"key": "Content-Length",
	"value": "117",
}, {
	"key": "Connection",
	"value": "keep-alive",
}, {
	"key": "CF-Ray",
	"value": "6a843f48afdbde7a-BOM",
}, {
	"key": "Cache-Control",
	"value": "public, max-age=607, s-maxage=607",
}, {
	"key": "ETag",
	"value": "\"6538726a453b6de7\"",
}, {
	"key": "Date",
	"value": "Wed, 03 Nov 2021 08:31:37 GMT",
}, {
	"key": "Content-Type",
	"value": "application/xml",
}, {
	"key": "Content-Length",
	"value": "117",
}, {
	"key": "Connection",
	"value": "keep-alive",
}, {
	"key": "CF-Ray",
	"value": "6a843f48afdbde7a-BOM",
}, {
	"key": "Cache-Control",
	"value": "public, max-age=607, s-maxage=607",
}, {
	"key": "ETag",
	"value": "\"6538726a453b6de7\"",
}, {
	"key": "Expires",
	"value": "Wed, 04 Nov 2021 06:04:47 GMT",
}, {
	"key": "Last-Modified",
	"value": "Wed, 03 Nov 2021 07:20:47 GMT",
}, {
	"key": "Vary",
	"value": "Accept-Encoding",
}, {
	"key": "CF-Cache-Status",
	"value": "DYNAMIC",
}, {
	"key": "Expect-CT",
	"value": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
}, {
	"key": "pragma",
	"value": "cache",
}, {
	"key": "Report-To",
	"value": "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=ZHAoChAaZtfZNjPLlvF1c44ontYMhmMcg3SZp0QU7z3FY7yGmFprNdIhGHoAU%2FC1z3mFYssDgdBWTptHgkECOZOZ%2BDiAmhRXzVdBLf7Oxu%2FuJB%2B%2BQmSro%2Fk6VwpZaf9WG0IUmDbjdmg%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}",
}, {
	"key": "NEL",
	"value": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}",
}, {
	"key": "Server",
	"value": "cloudflare",
}, {
	"key": "Server",
	"value": "cloudflare",
}

Wrong Port for Cloudflare Caching :wink:
According to https://support.cloudflare.com/hc/en-us/articles/218411427

Ports 80, 443, and 8080 are the only ports where Cloudflare Caching is available.

I thb do not understand why they dont allow it on 8443 as it is mostly used as SSL Port for 8080, but these are the rules …

3 Likes

@M4rt1n thanks a lot! I had fallen in a deep pit… Much before this i had ssl not working on port 8090 after which I discovered that 8443 was supported. Thus now it is indeed counter intuitive to have 443 supported for caching 8443 supported for ssl but not caching! Not being able to see any sort of debug log makes it worst… At the very least cloudflare should show warnings when wrong ports are being used. In my case if it would have simply said - “8443 is not supported for caching” when i was trying to add the page rule with cache everything - it would have saved me ~50 hours, and countless hours of so many others! Terrible!
I was planning to test it out on port 80/443 few steps down the line - and then proxify it via port 443. That’s what I will have to do now: cache some api through port 443.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.