Cache Rule - Bypass Cache not working based on User Agent

In our Cache Rules we try to exclude a specific User Agent from being cached by doing the following:
(http.user_agent contains “agent-abc”)

then: Cache Status: Bypass cache
As on the attached picture:

This is followed by another Cache Rule which caches everything (it comes after this rule)
Unfortunately, it looks like the User Agent based rule doesn’t work at tall because the page is still cached.

You can check it by accessing: and spoofing the agent-abc User Agent.

for cache rules, ordering matters and it’s different from page rules. Refer to Cache Rules (beta) · Cloudflare Cache (CDN) docs

but in your specific case, the first cache rule you have says if user agent contains x then bypass cache and the last cache rule you have says if url contains then cache everything. since both are setting conflicting cache settings when you have a request with user agent x for a url that matches the url you have in the last cache rule. The last cache rule takes priority and therefore we cache everything.


Thank you, this solves the issue.

If someone from the Cloudflare Product Team is reading this:
Who on Earth decided that the priority on Cache Rules should be based from bottom to the top (whereas Page Rules are applied from the top to the bottom)?

1 Like

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