Serve stale content based on user agent (crawlers)
Hi,
We have some aggressive crawlers, given there isn’t much of an out of the box rate limit solution… is it possible to craft the VCL to serve stale content?
We have our content stored for 1 day(often TTL of 2 hours~) as stale so it should be possible to serve all the crawlers the same stale cache rather than causing backend requests?
In our use case we not massively fussed if a web crawler gets an out of date page.
-
I just did a rudimentary test and it looks like it's possible. I created 2 VCL snippets: one for detecting the condition I wanted to serve stale on, and the other for actually serving stale. You'd have to check for
req.http.user-agent
instead.In vcl_recv ``` if (req.http.foo == "bar"){ error 901; }
```
In vcl_error
if (obj.status == 901) { if (stale.exists) { return(deliver_stale); } }
Please sign in to leave a comment.
Comments
3 comments