Skip to content

Commit 218a939

Browse files
committed
Enable serving from cache whilst revalidate, and if error
1 parent da9c6dc commit 218a939

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/MetaCPAN/Web/Controller/Root.pm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ Attempt to render a view, if needed.
113113
sub end : ActionClass('RenderView') {
114114
my ( $self, $c ) = @_;
115115

116+
# This will only affect if `cdn_max_age` has been set.
117+
# https://www.fastly.com/documentation/guides/concepts/edge-state/cache/stale/
118+
# If it has then do revalidation in the background
119+
$c->cdn_stale_while_revalidate('1d');
120+
# And if there is still an error serve from cache
121+
$c->cdn_stale_if_error('1y');
122+
116123
# for normal errors, try to render the internal_error page rather
117124
my @error = @{ $c->error };
118125
if ( @error && !$c->debug ) {

0 commit comments

Comments
 (0)