Cache homepage (on free plan)

My homepage is a static html file that I only update every few months or so, my website has been getting ddosed quite regularly (at least once every 2 days) but after looking at the logs I realise most ddos attacks just target the / route. I've been trying to cache it for 2 hours (so that cloudflare only fetches it once every 2 hours) but no matter how I setup the cache rules, it still seems to hit my origin server. Here are the settings I've enabled. * Custom filter expression - (http.request.full_uri eq "/") * Edge TTL - 2 hours * Browser TTL - 2 hours * Cache key - Ignore query string ✅ But I can see from my origin server that it's still being called every time someone goes on the homepage, any help would be greatly appreciated and if this isn't possible on the free plan, please let me know.
1 Reply
Oli
OliOP5d ago
Just to test, I the exact same cache rule to apply to all requests, and it then cached the homepage fine, so I'm guessing it's an issue with the custom filter expression? Also, with this rule, despite it supposed to cache for 2 hours, it does stop ALL requests going to origin but there is still more than 1, is there anyway to fix this or is this just default behaviour? I've figured out the issue, its because some users are passing queries (even though the homepage expects none, maybe crawler bots, etc?) but now I've found another one. If I pass any query, with Ignore query string enabled or not, instead of retrieving the cached version, it returns 2 cache-control headers, 1 of them is my normal header returned from the origin server but then I have another with no-cache and CF-Cache-Status is EXPIRED with a Last-Modified date that is over a month old (even though its showing the current version). I see that it's actually calling the webserver but it's not updating the cache, any ideas? For some reason the web framework I was doing was adding automatic cache headers, this has now been fixed and by using teired cache it only fetches origin once if cache has expired

Did you find this page helpful?