Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i do not get the result i want out in searching
I am making the Progressive web apllication (pwa) to work offline but my some of data is in folder which is very time consuming to wite all the dir in service worker js to cache is there any way to cache the entire folder

What I have tried:

JavaScript
<pre>self.addEventListener('install', e => {
    e.waitUntil(
        caches.open("spotify_clone").then(cache => {
            return cache.addAll(["./index.html", "./style.css", "./script.js", "./", "./songs/", "./5.jpg", "./songs/0.mp3", "./songs/1.mp3", "./songs/2.mp3", "./songs/3.mp3", "./songs/4.mp3", "./songs/5.mp3", "./BG.jpg", "./giphy.gif", "./manifest.json","./fontawesome <= this is the folder i want cache"])
        })
    )
})
self.addEventListener('fetch', e => {
    e.respondWith(
        caches.match(e.request).then(response => {
            return response || fetch(e.request)
        })
    )
})
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900