Overlapping page rules, priority, and workers


I’m using Cloudflare with an O2O proxy to one of our Shopify stores. I’m seeing some unexpected behavior with my page rules, and was wondering if anyone has some insight they could share. The relevant page rules (unrelated rules are omitted) look like:

  1. *origin/collections/*.json → cache everything, set edge TTL

  2. origin/collections/* → cache everything, set edge TTL, set browser TTL, cache by device, custom cache key (ignore query params)

Rule #1 is intended to offer mild edge caching for front-end API resources consumed by visitors.
Rule #2 works with and provides headers to a worker that rewrites HTML on that route. It sets subrequest caching times for and provides the device header to the worker. The unusual combination of “Cache everything” + ignore QS is required to bypass an apparent quirk of O2O with Shopify.

Potentially related – I have a different worker that makes subrequests matching rule 1. This worker also manages its own (longer-lived) cache for those resources.

I keep seeing an issue where rule #2 ends up applying to requests like origin/collections/path/resource.json. This causes some severe issues since the data at these endpoints is paginated.

Any ideas? Next thing I was going to try was eliminating the initial wildcard in rule 1, but I was hoping someone could explain what’s going on here.

I’ve been staring at this far too long! Of course rule #1 is getting bypassed. It won’t match requests with query parameters. Whoops!

I updated the rule to *origin/collections/*.json* and everything works as expected.

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