Merge "ResourceLoader: Add 1min grace via stale-while-revalidate Cache-Control"

This commit is contained in:
jenkins-bot 2022-12-07 22:10:30 +00:00 committed by Gerrit Code Review
commit 3173f253fb

View file

@ -921,7 +921,13 @@ class ResourceLoader implements LoggerAwareInterface {
header( 'Cache-Control: private, no-cache, must-revalidate' );
header( 'Pragma: no-cache' );
} else {
header( "Cache-Control: public, max-age=$maxage, s-maxage=$maxage" );
// T132418: When a resource expires mid-way a browsing session, prefer to renew it in
// the background instead of blocking the next page load (eg. startup module, or CSS).
$staleDirective = ( $maxage > self::MAXAGE_RECOVER
? ", stale-while-revalidate=" . min( 60, intval( $maxage / 2 ) )
: ''
);
header( "Cache-Control: public, max-age=$maxage, s-maxage=$maxage" . $staleDirective );
header( 'Expires: ' . ConvertibleTimestamp::convert( TS_RFC2822, time() + $maxage ) );
}
foreach ( $extra as $header ) {