Created
November 27, 2023 08:17
-
-
Save divyasonaraa/d990fab0cc8d9bd5383216849944d9f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Cache first, falling back to network | |
registerRoute( | |
({ url }) => url.host.startsWith("fonts.googleapi.com"), | |
new CacheFirst({ | |
cacheName: "google-fonts", | |
plugins: [ | |
new ExpirationPlugin({ | |
maxEntries: 30, | |
}), | |
new CacheableResponsePlugin({ | |
statuses: [0, 200], | |
}), | |
], | |
}) | |
); | |
//Network first, falling back to cache | |
registerRoute( | |
({ url }) => url.pathname.startsWith("/blogs"), | |
new NetworkFirst() | |
); | |
//Stale-while-revalidate | |
registerRoute( | |
({ url }) => url.protocol === "http:" || url.protocol === "https:", | |
new StaleWhileRevalidate() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment