Skip to content

Commit dc5fc66

Browse files
committed
Add surrogate/error cache to feeds end
1 parent ae0f4de commit dc5fc66

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/MetaCPAN/Web/Controller/Feed.pm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,17 @@ sub end : Private {
304304
my $feed = $c->stash->{feed};
305305
$c->detach('/end')
306306
if !$feed;
307+
308+
309+
# This will only affect if `cdn_max_age` has been set.
310+
# https://www.fastly.com/documentation/guides/concepts/edge-state/cache/stale/
311+
# If it has then do revalidation in the background
312+
$c->cdn_stale_while_revalidate('1d');
313+
314+
# And if there is still an error serve from cache
315+
$c->cdn_stale_if_error('1y');
316+
317+
307318
$c->res->content_type(
308319
$feed->isa('XML::FeedPP::Atom')
309320
? 'application/atom+xml; charset=UTF-8'

0 commit comments

Comments
 (0)