Skip to content

Commit

Permalink
fix(service-worker): fix condition to check for a cache-busted request (
Browse files Browse the repository at this point in the history
angular#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 angular#36847
  • Loading branch information
sonukapoor authored and josephperrott committed Aug 31, 2020
1 parent 38d6596 commit 5be4edf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/service-worker/worker/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ export abstract class AssetGroup {
// 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
// only valid to access the content of the first response if the request was successful.
let makeCacheBustedRequest: boolean = networkResult.ok;
if (makeCacheBustedRequest) {
let makeCacheBustedRequest: boolean = !networkResult.ok;
if (networkResult.ok) {
// 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
// if it proves to be valid.
Expand Down

0 comments on commit 5be4edf

Please sign in to comment.