Skip to content

Commit

Permalink
service-worker.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusef Almamari committed Jul 15, 2024
1 parent 30e6db9 commit 76d352a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ registerRoute(
);

registerRoute(
({ url }) => url.origin === self.location.origin && url.pathname.endsWith(/\.(png|jpg|jpeg|svg)$/),
({ url }) => {
const path = url.pathname.split("/");
const lastSegment = path[path.length - 1];
return url.origin === self.location.origin && ["png", "jpg", "jpeg", "svg"].includes(lastSegment);
},
new StaleWhileRevalidate({
cacheName: "images",
plugins: [new ExpirationPlugin({ maxEntries: 50 })],
Expand Down

0 comments on commit 76d352a

Please sign in to comment.