Skip to content

Instantly share code, notes, and snippets.

@julianrubisch
Last active January 11, 2020 07:15
Show Gist options
  • Save julianrubisch/b5f11f1dee4d6711b367a4ff0722f5f0 to your computer and use it in GitHub Desktop.
Save julianrubisch/b5f11f1dee4d6711b367a4ff0722f5f0 to your computer and use it in GitHub Desktop.
workbox webpack runtime cache
new WorkboxWebpackPlugin.GenerateSW({
clientsClaim: true,
exclude: [/\.map$/, /asset-manifest\.json$/],
importWorkboxFrom: "cdn",
runtimeCaching: [
{
urlPattern: new RegExp("https://images\.ctfassets\.net"),
handler: "cacheFirst"
},
{
urlPattern: new RegExp("https://cdn\.contentful\.com"),
handler: "cacheFirst"
},
{
urlPattern: new RegExp("http://video\.ctfassets\.net"),
handler: "cacheFirst"
}
],
navigateFallback: publicUrl + "/index.html",
navigateFallbackBlacklist: [
// Exclude URLs starting with /_, as they're likely an API call
new RegExp("^/_")
// Exclude URLs containing a dot, as they're likely a resource in
// public/ and not a SPA route
// new RegExp("/[^/]+\\.[^/]+$")
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment