[
https://issues.apache.org/jira/browse/CB-12804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16054531#comment-16054531
]
ASF GitHub Bot commented on CB-12804:
-------------------------------------
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);
}
)
);
```
> Cordova-browser PWA needs a manifest file
> -----------------------------------------
>
> Key: CB-12804
> URL: https://issues.apache.org/jira/browse/CB-12804
> Project: Apache Cordova
> Issue Type: Improvement
> Components: cordova-browser
> Reporter: Audrey So
> Assignee: Audrey So
> Fix For: cordova7
>
>
> Cordova-browser PWA needs a manifest file.
> This manifest.json file should get created during cordova platform add
> browser and use values from config.xml to build.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]