Skip to content

Commit

Permalink
Implementation will be smart enough to pull fresh content from other …
Browse files Browse the repository at this point in the history
…caches
  • Loading branch information
jakearchibald committed Sep 26, 2013
1 parent e1718f8 commit f270440
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions examples/single-page-app/example.com/ctrl.js
Expand Up @@ -6,33 +6,15 @@ var cacheNames = {

// Install process
this.oninstalled = function(event) {
var staticCache = new Cache();
var oldStaticCache;
// TODO: how can we avoid downloading both PNGs?
// https://github.com/slightlyoff/NavigationController/issues/60
var staticUrls = [
caches.set(cacheNames['static'], new Cache(
'//cdn.example.com/all-v1.css',
'//cdn.example.com/all-v1.js',
// TODO: how can we avoid downloading both PNGs?
// https://github.com/slightlyoff/NavigationController/issues/60
'//cdn.example.com/whatever-v1.png',
'//cdn.example.com/whatever-large-v1.png',
'//cdn.example.com/whatever-v1.woff'
];

if (event.previousVersion) {
oldStaticCache = caches.get('static' + event.previousVersion);
}

staticUrls.forEach(function(staticUrl) {
// copy from previous cache, if it's there
if (oldStaticCache && oldStaticCache.has(staticUrl)) {
staticCache.set(staticUrl, oldStaticCache.get(staticUrl));
}
else {
staticCache.add(staticUrl);
}
});

caches.set(cacheNames['static'], staticCache);
));

// core cache entried should be check on each controller update
caches.set(cacheNames['core'], new Cache([
Expand Down

0 comments on commit f270440

Please sign in to comment.