0
votes

Few image urls are valid but still some times service worker caches 404 response even after applying below condition:

if(response.status < 400){
    cache.put(event.request, response.clone());
}

and after that it responses 404 until I hard reloaded the page. Any solution for this?

1

1 Answers

0
votes

Opaque responses always have a status code of 0 from the perspective of your service worker. The "real" response might be a 200 or a 404 or something else, but your service worker code wouldn't be able to tell. I'm guessing that might explain the behavior you're seeing.