Trying to set up service worker for caching, it never installs

38 Views Asked by At

So, I am trying to build a PWA and I am just getting familiar with caching/service workers. I found some examples online that all seem to be the same, and I am trying to cache a few of my routes. However, it simply doesn't do anything.

const staticCache = "myApp";

const assets = [
    "/",
    "/session",
    "/login",
    "/logout",
    "/register",
    "/account/create",
    "/accounts/balance",
    "/categories/new",
];

self.addEventListener("install", (event)=>{
    console.log("installed");
    event.waitUntil(
        caches.open(staticCache)
            .then((cache)=>{
                return cache.addAll(assets);
            })
    )
});

When this runs, the "installed" is never printed. So it never installs, nothing happens. Am I missing something here? Did I miss a step? Thanks in advance.

0

There are 0 best solutions below