-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplicationCache.js
43 lines (30 loc) · 1.27 KB
/
applicationCache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
window.addEventListener('load', function(e) {
var applicationCache = window.applicationCache;
// After the first cache.
applicationCache.addEventListener('cached', handleCacheEvent, false);
// Checking update.
applicationCache.addEventListener('checking', handleCacheEvent, false);
// Update founded - Fetching resources.
applicationCache.addEventListener('downloading', handleCacheEvent, false);
// Returns a status of 404 or 410 (Download failed or changing was in progress)
applicationCache.addEventListener('error', handleCacheError, false);
// After the first download.
applicationCache.addEventListener('noupdate', handleCacheEvent, false);
// Return a status of 404 or 410.
// Results will be deleted.
applicationCache.addEventListener('obsolete', handleCacheEvent, false);
// Fetch every resource listed.
applicationCache.addEventListener('progress', handleCacheEvent, false);
// New download.
applicationCache.addEventListener('updateready', handleCacheEvent, false);
}, false);
function handleCacheEvent(e) {
log("Application Cache - " + e.type + " Event");
console.log(e);
}
function handleCacheError(e) {
log("Application Cache - Error: " + e.data);
}
function log(text){
console.log(text);
}