fix(service-worker): fix condition to check for a cache-busted request (#36847)

Previously, the condition to make the cache busted was executing although
the network request was successful. However, this is not valid. The cache
should only be marked as busted when the request failed. This commit fixes
the invalid condition.

PR Close #36847
This commit is contained in:
Sonu Kapoor 2020-07-28 08:41:15 -04:00 committed by Joey Perrott
parent 38d6596742
commit 5be4edfa17
1 changed files with 2 additions and 2 deletions

View File

@ -393,8 +393,8 @@ export abstract class AssetGroup {
// reasons: either the non-cache-busted request failed (hopefully transiently) or if the // reasons: either the non-cache-busted request failed (hopefully transiently) or if the
// hash of the content retrieved does not match the canonical hash from the manifest. It's // hash of the content retrieved does not match the canonical hash from the manifest. It's
// only valid to access the content of the first response if the request was successful. // only valid to access the content of the first response if the request was successful.
let makeCacheBustedRequest: boolean = networkResult.ok; let makeCacheBustedRequest: boolean = !networkResult.ok;
if (makeCacheBustedRequest) { if (networkResult.ok) {
// The request was successful. A cache-busted request is only necessary if the hashes // The request was successful. A cache-busted request is only necessary if the hashes
// don't match. Compare them, making sure to clone the response so it can be used later // don't match. Compare them, making sure to clone the response so it can be used later
// if it proves to be valid. // if it proves to be valid.