cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From macdonst <...@git.apache.org>
Subject [GitHub] cordova-browser pull request #32: CB-12804 : support manifest.json
Date Mon, 19 Jun 2017 18:29:36 GMT
Github user macdonst commented on a diff in the pull request:

    https://github.com/apache/cordova-browser/pull/32#discussion_r122785379
  
    --- Diff: bin/template/www/cordova-sw.js ---
    @@ -0,0 +1,23 @@
    +
    +// Note, these will be updated automatically at build time
    +var CACHE_VERSION = '%CACHE_VERSION%';
    +var CACHE_LIST = ['CACHE_VALUES'];
    +
    +this.addEventListener('install', function(event) {
    +    // Perform install steps
    +    console.log("cordova service worker is installing.");
    +    event.waitUntil(caches.open(CACHE_VERSION)
    +    .then(function(cache) {
    +        return cache.addAll(CACHE_LIST);
    +    }));
    +});
    +
    +this.addEventListener('activate', function(event) {
    +    // Perform activate steps
    +    console.log("cordova service worker is activated.");
    +});
    +
    +this.addEventListener('fetch', function(event) {
    +    console.log("cordova service worker : fetch : " + event.request.url);
    +    event.respondWith(caches.match(event.request));
    --- End diff --
    
    All the examples I've seen from Google program this a bit more defensively:
    
    ```
      event.respondWith(
        caches.match(event.request)
          .then(function(response) {
            // Cache hit - return response
            if (response) {
              return response;
            }
            return fetch(event.request);
          }
        )
      );
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message