Page Rule Cache Level: Standard equivalent in Cache Rules

Hi,

We’re trying to convert individual Page Rule to Cache Rule, but it doesn’t seem to behave the same way
ex:

Catch all
.test.com/
Cache Level: Cache Everything, Origin Cache Control: On

Page Rule
www.test.com > Cache Level: Standard

Cache Rule
(http.host eq “www.test.com”)

Eligible for cache

Also tested configuring
Edge TTL > Respect origin
Browser TTL > Respect origin

www.test.com/v2?namespace=0&opts123 JSON response becomes cached with Cache rule, while the origin response header has no cache header

HTTP/1.1 200 OK
Date: Tue, 29 Aug 2023 02:53:10 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 294
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE
Access-Control-Allow-Headers: Access-Token, X-Requested-With, Content-Type, Accept
ETag: W/"126-d6/6LIfOVrnTbHe7iQ/yO8HPcKU"
Vary: Accept-Encoding

With Cache Rule

Access-Control-Allow-Headers:
Access-Token, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Methods:
GET, POST, PUT, OPTIONS, DELETE
Access-Control-Allow-Origin:
*
Age:
22
Alt-Svc:
h3=":443"; ma=86400
Cf-Cache-Status:
HIT
Cf-Ray:
7fe18f4e9ccef661-NRT
Content-Encoding:
br
Content-Type:
application/json; charset=utf-8
Date:
Tue, 29 Aug 2023 03:03:15 GMT
Etag:
W/"130-pyRoshPT/nkaBGucusr6N13FqAA"
Server:
cloudflare
Vary:
Accept-Encoding

Hi,

With Cache Rules, you can create matching patterns that are a lot more flexible than with Page Rules. For instance:

could become, for instance:

http.host eq "www.test.com" AND http.request.uri.path ne "/v2"

Hi,

Yes, we are aware of that, but this means we need multiple rules to reflect/construct what a single Cache Level: Standard does?

We have other page rules/hierarchy that needs to be moved/converted so if this is the only way, we need to review every the hierarchy and come up with a new set of rules to define instead of converting them one by one

There are several ways to go about this migration. But if I understood your goal well, you could add exceptions right in the rule that sets cache to "Eligible for cache’, which is the equivalent to “Cache Everything” in Page Rules:

When incoming requests match...
http.host eq "www.example.com" AND not http.request.uri.path in {/path1 /path2 etc.}

This would be the operator “is not in” in the Expression Builder.

So with just one rule you set your website to Cache Everything, while excluding a list of paths that would then follow the default Cache Setting set at Dashboard > Caching > Configuration.

1 Like

Thanks for suggestion but we don’t want to define which path we need to cache, all we want is the Standard cache behavior default by CF

Standard cache level is literally the default. That’s your starting point. If you start messing with Query strings in your rule, you may end up changing the cache level:

Create a Cache Rule that Bypasses Cache if there’s a query string, then you’ve got the No Query String setting.

Create a Cache Rule with “eligible for cache” where Cache Key sets Query String to “Ignore Query String”, then you’ve got…Ignore Query String.

Create a Cache Rule that sets Eligible For Cache that matches resources not normally eligible cache, such as HTML, and now you’ve got Cache Everything.

Even better, you can mix and match some of the above.

And if a request doesn’t match any of your rules, you’ve got Standard Cache Level.

1 Like

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