I’m admin’ing a regional weather forecasting site running Wordpress. Most users like to access the site via an app, and that app mercilessly thrashes mysite.com/feed/ to keep the app’s content current with the site. (There are lots of reasons for the app developer having done it this way and I can’t change this.)
In order to mitigate the load on my origin server of ~50-100k uniques slamming into /feed/ on the origin server every day as updates are posted, I’m attempting to configure Cloudflare via page rule to hang onto /feed/ with a somewhat short expiry so that the screaming hoard of people hungry for their daily forecast can be serviced from CF’s edge cache.
…but it’s not working. Not even a little bit. Every single request for /feed/ from every single client gets returned with cf-cache-status: MISS in the response headers and gets thrown back to the origin server.
What the ■■■■ am I missing? This feels like it should be super straightforward and it’s making me feel incredibly stupid.
That indicates that your server was responding with a HTTP Status other then 200 (which stands for success)
Which I think is not cool as your server responds with a “304” which stands for contend did not change. Ofc the 304 should not be cached but the first 200 instead, or a new request should be cached. But like this all people just bypass Cloudflares cache. I also wonder why the first request (which cant be an 304) was not getting cached.
In a case of a 304 with Cache MISS a Cloudflare should request a fresh copy no matter what and cache it.
BTW the first PageRule will not cover any other feed then the one from your startingpage.
Check: https://spacecityweather.com/pretty-nice-weather-for-july-comes-to-houston-this-week/feed/ is not getting matched by the rule.
Pls change the rule to:
Thanks—let me try that real quick. /feed (no trailing slash) gets redirected to /feed/ (with trailing slash), so I’d originally wanted to use /feed* so that CF would also capture and cache the 301 redirect and save me 200ms or so of origin server time on doing the redirects.
While I have your attention, may I ask one other dumb question?
Should pagerules contain the scheme at the beginning? I don’t have a scheme in any of my existing ones—I just start with the hostname. I can’t seem to find a consistent answer to this. Some of the CF page rule examples omit the scheme, and some have it. A solid yes or no would be really helpful.
On a proper setup I would recommend it. But to pass that ball back to you I will just explaion what it does and how it behaves without scheme and you can decide what you want to go for.
The rule spacecityweather.com/ matches: http://spacecityweather.com and https://spacecityweather.com
so it will even cache HTTP requests if they are getting answered by your origin server with a status code of “200”.
The rule https://spacecityweather.com/ matches: https://spacecityweather.com. So just the HTTPS version. This is my prefered way of a pagerule if you want to cache static content and you know you enabled HSTS and you serve everything from HTTPS (encrypted) anyway.
Thank you, @yegven. What should I see on my end? Do I need to adjust my page rules, or will /feed/ simply begin showing up with cf-cache-status: HIT? Just want to make sure I’m doing everything that I’m supposed to be doing to make things work right.