Skip to content

Commit

Permalink
only cache 200 responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Nov 27, 2022
1 parent cde0903 commit a67666e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion documentation/docs/30-advanced/40-service-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ self.addEventListener('fetch', (event) => {
// fall back to the cache if we're offline
try {
const response = await fetch(event.request);
cache.put(response.clone());

if (response.status === 200) {
cache.put(response.clone());
}

return response;
} catch {
return cache.match(event.request);
Expand Down

0 comments on commit a67666e

Please sign in to comment.