Library Affected:
workbox-sw, though I'm using [email protected]
Browser & Platform:
All browsers
Issue or Feature Request Description:
If I need to support a various spectrum of browsers, I would have to provide different font formats for them. I want them to be cached through Service Worker, so I would configure workbox-webpack-plugin to something like this:
new WorkboxBuildWebpackPlugin({
globDirectory: path.resolve(__dirname, 'public'),
globPatterns: [
'fonts/**/*.{eot,svg,ttf,woff,woff2}'
]
})
But the Service Worker will cache all font files for every browser, even if it doesn't need all the formats (for example, Chrome only needs WOFF2).
I don't know if it's possible and if it would be reasonable to make it a default, but could we check the formats supported by the browser and cache only those?
This is a good idea, but I can't see us getting to this any time soon and as a first step we need to find a better way of injecting the precache list so you could manipulate it before passing the details to the precache() function as this would at least allow you to write the code to filter out assets based on your needs.
@gauntface I get your point, fonts are a specific case and having a generic way to manipulate the precache list would benefit a lot of different use cases. Is there already any work in progress around this?
At the moment we are getting the workbox-build and webpack modules in a healthier state / working with webpack a little better. After that and V3 is landed, we should hopefully get to spend time on this.
Great, thanks for your answers :) In the meantime I will try to find a way to feature detect font format support in a given browser because I'm not even sure if it's possible.
FWIW, since every browser that currently supports service workers also supports woff2, just precaching the woff2 format sounds relatively safe to me.
That's even better!
Most helpful comment
FWIW, since every browser that currently supports service workers also supports
woff2, just precaching thewoff2format sounds relatively safe to me.