Skip to content

Commit

Permalink
Add data resources to SW caching. (Notes follow)
Browse files Browse the repository at this point in the history
NB. Currently, updating the data resource files will not make the
service worker re-cache them. The service worker file itself will
need to be updated. However, browser are working on this. See:
w3c/ServiceWorker#839
  • Loading branch information
poshaughnessy committed Jun 19, 2017
1 parent 8a6a30c commit 5f6b864
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script src="lib/papaparse.js"></script>
<script src="lib/moment.js"></script>
<script src="lib/chartist.js"></script>
<script src="src/data-paths.js"></script>
</head>
<body>
<header>
Expand Down
3 changes: 0 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
var mediumStatsCSVPath = 'data/medium-stats-overview-2017-06-14.csv';
var statsJSONPath = 'data/stats-2017-06-14.json';

var twitterSurveyAwarePercent = 37;
var eventSurveyAwarePercent = 40;

Expand Down
9 changes: 7 additions & 2 deletions sw.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
'use strict';

importScripts('lib/sw-toolbox.js');
importScripts('src/data-paths.js');

var precacheList = [
'index.html',
'src/index.js',
'images/favicon.png',
'images/icon192.png',
'images/icon512.png',
'images/samsung-internet-logo-text.svg'
]
'images/samsung-internet-logo-text.svg',
mediumStatsCSVPath,
statsJSONPath
];

console.log('precacheList', precacheList);

toolbox.precache(precacheList);

Expand Down

0 comments on commit 5f6b864

Please sign in to comment.