PWA Not Registering

I based a PWA off of a codelab from Google:

Image of Issue


 * @license
 * Your First PWA Codelab (
 * Copyright 2019 Google Inc. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License
'use strict';

// CODELAB: Update cache names any time any of the cached files change.const CACHE_NAME = 'static-cache-v2';
const CACHE_NAME = 'static-cache-v2';
const DATA_CACHE_NAME = 'data-cache-v1';

// CODELAB: Add list of files to cache here.
const FILES_TO_CACHE = [

self.addEventListener('install', (evt) => {
  console.log('[ServiceWorker] Install');
  // CODELAB: Precache static resources here.
  evt.waitUntil( => {
      console.log('[ServiceWorker] Pre-caching offline page');
      return cache.addAll(FILES_TO_CACHE);


self.addEventListener('activate', (evt) => {
  console.log('[ServiceWorker] Activate');
  // CODELAB: Remove previous cached data from disk.
    caches.keys().then((keyList) => {
      return Promise.all( => {
        if (key !== CACHE_NAME) {
          console.log('[ServiceWorker] Removing old cache', key);
          return caches.delete(key);


self.addEventListener('fetch', (evt) => {
  console.log('[ServiceWorker] Fetch', evt.request.url);
  // CODELAB: Add fetch event handler here.
  if (evt.request.url.includes('')) {
  console.log('[Service Worker] Fetch (data)', evt.request.url);
  evt.respondWith( => {
        return fetch(evt.request)
            .then((response) => {
              // If the response was good, clone it and store it in the cache.
              if (response.status === 200) {
                cache.put(evt.request.url, response.clone());
              return response;
            }).catch((err) => {
              // Network request failed, try to get it from the cache.
              return cache.match(evt.request);
evt.respondWith( => {
      return cache.match(evt.request)
          .then((response) => {
            return response || fetch(evt.request);


Can someone help me out here?

What kind of help are you seeking? What are you expecting the code to do vs. what it is doing? Are you seeing any errors in the browser console?

The issue is that the PWA won’t install because the start_url is not there or something, however, I don’t know how to put it in. The image is the Chrome’s DevTools Lighthouse showing the problem.

Do you have your full project available to show on Glitch?


there were mistakes in multiple places. but you want this result yes:

here is the your project remixed, i just changed around some stuff in index.html and in your service worker file, it passes those tests now… Hope this can help you:

Yes. I would like the result to be that.

Thank you. I appreciate it.

1 Like

Also, I have noticed with the service worker, the website I tried to cache in the first glitch version I posted refuses to go into cache. It is not a static page, I suspect that is why, but I don’t know for sure. I still can’t post links and I’m on mobile rn so…