Page Rules Order

Hi all, I’m struggling to understand how the ordering of page rules work…

We currently have the following page rules:

    • *example.com/section1/*
      Browser Cache TTL: a year, Cache Level: Cache Everything, Edge Cache TTL: a month
    • *example.com/section2/*
      Browser Cache TTL: a year, Cache Level: Cache Everything, Edge Cache TTL: a month

So we have Section 1 and Section 2 completely cached - including all PHP files (There is nothing dynamic in there anyway)

What we want to do now is add this page rule:

    • *example.com/*
      Browser Cache TTL: a year, Cache Level: Cache Everything, Edge Cache TTL: a month, Bypass Cache on Cookie: cookie1|cookie2

Which will cache everything on our site - the index.php, etc.

BUT – when the cookie is present in rule 3, we still want rules 1 and 2 to function - so even if the cookie disables the cache on /index.php, if a cookie user goes to example.com/section1/ We still want everything to be cached (including all php files)

Should the rules order be:

1
2
3

or

3
1
2

Many thanks!

Page rules are interpreted from top to bottom - so your more specific rules must always go at the top.

Hence you want 1,2,3 here.

Remember only a single rule can match at any one time - there’s no “additive” effect - the rule that matches first (from top to bottom) wins. Hence your bypass cache on cookie rule would be ignored for requests that match either rule 1 or 2.

1 Like

Sorry Simon,

I’m still a bit confused :confused:

So if one of my “cookie signed in users” - is visiting the site…

Rule 1 - cache all of section 1
Rule 2 - cache all of section 2

Rule 3 - cookie is set - so DO NOT CACHE example.com/

Does Rule 3, then wipe out the caching of Rules 1 and 2? Making the whole site uncached?

Thanks again for the help.

The rules are interpreted in order and only one rule can match for a given request. Therefore, it would be impossible for Rule 3 to “wipe out” rules 1 or 2, since rules 1 and 2 run before 3.

2 Likes

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