I want to make my legacy ASP .NET MVC5 project to PWA so i'm setting service worker.
And i want Project file in /Views/Home/ directory be cached.
So I added cache list like this.
const CACHE_NAME = "cache";
const CACHE_LIST = [
"/",
"/Views/",
"/Views/Home/",
"/Views/Home/Project"
]
const addResourcesToCache = async (resources) => {
const cache = await caches.open(CACHE_NAME);
await cache.addAll(resources);};
}
self.addEventListener('install', (event) => {
self.skipWaiting();
event.waitUntil(
addResourcesToCache(CACHE_LIST)
);
});
But It didn't worked. It occurs error.
Uncaught (in promise) TypeError: Failed to execute 'addAll' on 'Cache': Request failed
I've tried Is there any way to cache all files of defined folder/path in service worker? but doesn't worked.
And I changed cache list like this and it worked.
(http://localhost:23402/subdomain1/subdomain2/subdomain3/ is url about Project file.)
const CACHE_LIST = [
"/",
"http://localhost:23402/subdomain1/subdomain2/subdomain3/"
]
But i have to cache all files in my legacy project so i can't register cache one by one like that.
I want to cache all files with file path not url.
How can i solve this problem?