`runtimeCaching` doesn't use the `directoryIndex` option
See original GitHub issueLibrary Affected: workbox-runtime-caching
Browser & Platform: Google Chrome 72.0
Issue or Feature Request Description:
runtimeCaching
doesn’t seem to use the directoryIndex
option.
I want to serve and cache /index.html
with runtimeCaching
networkFirst
approach, for all the routes ending in /
.
Using urlPattern: 'index.html'
doesn’t seem to work at all, while using urlPattern: /\/$/,
makes every different pathname ending in /
to be cached separately.
generateSW config
{
skipWaiting: true,
clientsClaim: true,
exclude: [
/\.map$/,
/^manifest.*\.js$/,
'index.html'
],
runtimeCaching: [
{
urlPattern: '/\/$/',
// Apply a network-first strategy.
handler: 'networkFirst',
}]
}
service-worker.js
/**
* Welcome to your Workbox-powered service worker!
*
* You'll need to register this file in your web app and you should
* disable HTTP caching for this file too.
* See https://goo.gl/nhQhGp
*
* The rest of the code is auto-generated. Please don't update this file
* directly; instead, make changes to your Workbox build configuration
* and re-run your build process.
* See https://goo.gl/2aRDsh
*/
importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js");
importScripts(
"/precache-manifest.32b375c53995d3f7716830693a179759.js"
);
workbox.core.setCacheNameDetails({prefix: "web"});
workbox.skipWaiting();
workbox.clientsClaim();
/**
* The workboxSW.precacheAndRoute() method efficiently caches and responds to
* requests for URLs in the manifest.
* See https://goo.gl/S9QRab
*/
self.__precacheManifest = [].concat(self.__precacheManifest || []);
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
workbox.routing.registerRoute("index.html", workbox.strategies.networkFirst(), 'GET');
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
workbox-build - Chrome Developers
This method creates a list of URLs to precache, referred to as a "precache manifest", based on the options you provide. It also...
Read more >Using sw-precache configured with runtimeCaching is not ...
I have installed grunt-sw-precache. The issue is that the service-worker.js file which is created does not include any runtime caching code at ...
Read more >mod_dir - Apache HTTP Server Version 2.4
The DirectoryIndex directive sets the name of this file. ... If none of the resources exist and the Indexes option is set, the...
Read more >Workbox Module - Nuxt PWA
(Object) Options to be passed to workbox before using it's modules. ... (String/Regex) Pattern to match assets for runtime caching.
Read more >gatsby-plugin-offline-next - npm package - Snyk
Ensure you're using the healthiest npm packages ... The runtimeCaching option is no longer supported in 5.x. If you previously used custom ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@guins @jeffposnick how do you import workbox in the
GenerateSW
configuration file?Yup,
directoryIndex
only applies to precaching.You’re going to need to write a custom handler to do that. Based on what you describe, the following would work: