Help Understanding Page Rules and Overwriting Origin Headers

pagerules
caching
wordpress

#1

I find myself confused by two points, despite a lot of documentation. I’m hoping someone can help me to understand a couple of things. As a point of reference, we moved from using Varnish in front of WP to using Cloudflare.

  1. With page rules, it says only one rule will be applied per matched pattern. It also says that the “Always Use HTTPS” page rule has to be set alone, i.e. you can’t add other settings with it in the same page rule. So, say I have a page rule set as #1 that says “match against http://mydomain.com/” and apply the Always Use HTTPS rule. I then also want to set a rule for a subdomain matching “mysubdomain.mydomain.com/*” for caching. Does this mean that if I put my subdomain rule first and someone hits that url it will only have the caching page rule associated with it and then not the HTTPS rule, and vice versa? How would you then manage to both apply the HTTPS rule to everything, and also specify caching behavior?

  2. I just set Cloudfront up in front of a Wordpress installation that I don’t manage. From that installation I can see that there are headers set that prevent caching
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    In Varnish I was able to specifically unset headers from the origin and set them to what I needed. The things I’ve read in the CF docs say both that:

  • Cloudflare will automatically cache files with a specific set of extensions, unless the cache-control headers explicitly say not to, in which case it will not cache anything
  • You can cache anyway by using a combination of Cache Everything and Edge Cache TTL

My question there is, how exactly can I override the headers coming from Wordpress to allow caching?


#2
  1. You can now set always use https on the crypto tab and apply it to all your sites and don’t need to use a page rule. But http://example.com and https://subdomain.example.com would be different based on the scheme (http vs. https)…

  2. I don’t believe there is a way to override this today (we assume the origin knows that it is doing/ is controlled by the zone owner). This may be possible in workers (I don’t think it is yet, but I could be wrong).


#3

This topic was automatically closed after 14 days. New replies are no longer allowed.