title: How to check for installed web app (PWA) updates when using precache method
body: <p>I have a Progressive Web App in which the service worker is configured as shown below. I follow precache method. Every files will be cached first and the requests will be served from the cache. If there is no match in local cache, then request is served over network. If everything fails an offline/error page is shown. Everything works fine. But I am stuck at giving an update to the index.html file.</p>
  <pre><code>const pb_cache = &quot;cv1&quot;;
  const assets = [
      &quot;./manifest.json&quot;,
      &quot;./index.html&quot;,
      &quot;./offline.html&quot;,
  ]
  
  self.addEventListener(&quot;install&quot;, installEvent =&gt; {
    installEvent.waitUntil(
      caches.open(pb_cache)
      .then((cache) =&gt; {
        return cache.addAll(assets)
        .then(() =&gt; {
          return self.skipWaiting(); //To forces the waiting service worker to become the active service worker
        })
      })
    );
  });
  
  self.addEventListener('fetch', function(event) {
    event.respondWith(
      caches.match(event.request).then(function(response) {
        if (response) {
          return response;
        }
        return fetch(event.request).then(function(response) {
          if (response.status === 404) {
            return caches.match('/offline.html');
          }
          return response
        });
      }).catch(function() {
        return caches.match('/offline.html');
      })
    );
  });
  </code></pre>
  <p><strong>Scenario</strong>
  I have installed the web app to my android phone. Everything is cached and works fine. I need to make changes to the index.html file. So i have added a few tweaks to the file and updated the website. But since the web app installed in android serves local cache, the change in website is not reflected. So I need a mechanism to check for update. What parameter or what thing should I check for update ? I have read many documents related to this and I am not able to grasp the content.</p>
  <p>One thing I know is that I have to check for update somewhere in service worker and add it to cache when found in network. I don't know which event or what criteria to check for.</p>