Cache rule won't work if set to respect origin

I have a Cache Rule (beta) like:

( eq "" and not http.request.uri.query matches ".+[=]?.*")

Cache status: Eligible for cache
Edge ttl: respect origin

In this configuration caching does not work at all. Repsonse CF-Cache-Status is always BYPASS.
If I set:
Edge ttl: override origin
Then the cache works, but cache-control headers are ignored (also CDN-Cache-Control or Cloudlfare-CDN-Cache-Control).

How do I get it to respect the cache-control headers?

What is that regular expression supposed to do?

That basically matches all non-empty strings, and with your negation you essentially block the rule, except when the query string is empty.

1 Like

The point is to cache all calls for which the query string is empty The following should be cached:


the next should not be:

So if the query string is empty then cache. Like I said, the rule works only if I set override origin. But then it does work.

I almost assumed so :slight_smile:. Thanks for the clarification. Try

http.request.uri.query ne ""

Or eq, depending on what you configure.

Matching against ā€œā€ does not work. I donā€™t know the internals of how CF matches the query string, but if there is no query string it does not match with ā€œā€. However, it does match with the RegEx I used. But it will never respect origin.

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