ostark / upper

Integrates Edge Caches like Fastly, KeyCDN, Cloudflare and Varnish with Craft.
MIT License
102 stars 22 forks source link

URLs that 404 get added to the upper_cache table #22

Closed petetak closed 5 years ago

petetak commented 5 years ago

If you get a lot of 404s then this can lead to further issues.

In EventRegistrar.php line 99 a check could be added, although you might want to call a method that checks for other status codes as well, or only insert a 200 code.

if ($response->hasCacheControlDirective('private') || $response->hasCacheControlDirective('no-cache') || $response->statusCode == 404) {
ostark commented 5 years ago

Caching 404's is not bad thing - it's kind of intentional. @petetak What's your actual issue?

petetak commented 5 years ago

I'm using Cloudflare and I quickly go over the 500 url limit when upper calls to invalidate a page.

It's maybe an edge case but it's a new site that is running on the same domain as an old site, so there are many 404s coming in (which I can fix with some redirects which should stop this issue for now)

But it kind of made me wonder if 404s in the upper table would ever get removed since they are not actual real craft entries

ostark commented 5 years ago

If you have a custom 404 template you can control the cache behaviour with

{% header "Cache-Control: private, no-cache" %}

Does this solve your issue?


I'll review Cloudflare's API limits again and try to avoid them.

petetak commented 5 years ago

Thanks @ostark that works - that's a much better solution!