When I just use pre-cache from Workbox Plugin, the service worker try to fetch from indexdb instead of cache(browser-cache).
Yes, service worker is faster than fetching from server. However, if it fetches from memory it takes 0 second.
I have seen all the strategies from workbox but it does not have a strategy that try to fetch from memory first.
This is everything for pre-cache.
new WorkboxPlugin.GenerateSW({
skipWaiting: true,
importWorkboxFrom: 'local',
})
service-worker.js
importScripts("/dist/workbox-v3.6.3/workbox-sw.js");
workbox.setConfig({modulePathPrefix: "/dist/workbox-v3.6.3"});
importScripts(
"/dist/precache-manifest.4b8be844a396ff2fc7335cebbab35f10.js"
);
workbox.skipWaiting();
/**
* The workboxSW.precacheAndRoute() method efficiently caches and responds to
* requests for URLs in the manifest.
*/
self.__precacheManifest = [].concat(self.__precacheManifest || []);
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});