DEV Community

Ola Johansson
Ola Johansson

Posted on

1

Notes about Cloudflare cache and json

I have spent a lot of time trying to understand how to setup cache for json and API requests in Cloudflare lately and finally i have made some progress. This is not a step by step guide but mostly a "notes to self" post so i can make some more sense of it all.

  • If workers are active on a route page rules are ignored. Took me a while to realize this.

  • Cloudflare only execute ONE page rule per request, so make sure the rules are in the correct order and you don't have any "catch all" rule at the top.

  • Also note that the above note is not applied to workers route, with workers the routes is matched by how detailed they are. I.e domain.com/test is used even if domain.com/* exist and the order doesn't matter.

After you know this it should simply be to set a custom page rule on the path you want to cache with the option

Cache Level: Cache Everything

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay