Bug 1611651 - Add pref for stale-while-revalidate r=dragana

Differential Revision: https://phabricator.services.mozilla.com/D65813

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Valentin Gosu 2020-03-10 19:04:43 +00:00
parent fd2cf8c108
commit 340feb823a
3 changed files with 11 additions and 1 deletions

View File

@ -7366,6 +7366,11 @@
value: true
mirror: always
- name: network.http.stale_while_revalidate.enabled
type: RelaxedAtomicBool
value: true
mirror: always
# Single TRR request timeout, in milliseconds
- name: network.trr.request_timeout_ms
type: RelaxedAtomicUint32

View File

@ -423,7 +423,8 @@ bool ValidationRequired(bool isForcedValid,
LOG((" not validating, expire time not in the past"));
} else if (cachedResponseHead->MustValidateIfExpired()) {
doValidation = true;
} else if (cachedResponseHead->StaleWhileRevalidate(now, expiration)) {
} else if (cachedResponseHead->StaleWhileRevalidate(now, expiration) &&
StaticPrefs::network_http_stale_while_revalidate_enabled()) {
LOG((" not validating, in the stall-while-revalidate window"));
doValidation = false;
if (performBackgroundRevalidation) {

View File

@ -10569,6 +10569,10 @@ NS_IMPL_ISUPPORTS(BackgroundRevalidatingListener, nsIStreamListener,
} // namespace
void nsHttpChannel::PerformBackgroundCacheRevalidation() {
if (!StaticPrefs::network_http_stale_while_revalidate_enabled()) {
return;
}
LOG(("nsHttpChannel::PerformBackgroundCacheRevalidation %p", this));
Unused << NS_DispatchToMainThreadQueue(