sw-appcache-behavior
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -799,4 +799,26 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
// TODO: Handle manifest fetch failure errors. | ||
// TODO: Consider cache-busting if the manifest response > 24 hours old. | ||
fetch(manifestRequest).then(function(manifestResponse) { | ||
var dateHeaderValue = manifestResponse.headers.get('date'); | ||
if (dateHeaderValue) { | ||
var manifestDate = new Date(dateHeaderValue).valueOf(); | ||
// Calculate the age of the manifest in milliseconds. | ||
var manifestAgeInMillis = Date.now() - manifestDate; | ||
// If the age is greater than 24 hours, then we need to refetch without | ||
// hitting the cache. | ||
if (manifestAgeInMillis > (24 * 60 * 60 * 1000)) { | ||
var noCacheRequest = new Request(manifestUrl, { | ||
credentials: 'include', | ||
// See https://fetch.spec.whatwg.org/#requestcache | ||
cache: 'reload', | ||
headers: { | ||
'X-Use-Fetch': true | ||
} | ||
}); | ||
return fetch(noCacheRequest).then(function(noCacheResponse) { | ||
return noCacheResponse.text(); | ||
}); | ||
} | ||
} | ||
return manifestResponse.text(); | ||
@@ -803,0 +825,0 @@ }).then(function(text) { |
{ | ||
"name": "sw-appcache-behavior", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A service worker implementation of the behavior defined in a page's App Cache manifest.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -18,3 +18,3 @@ # sw-appcache-behavior | ||
[projects/sw-appcache-behavior/src/appcache-behavior-import.js:501-514](https://github.com/GoogleChrome/sw-helpers/blob/f2d1b9af36cfc912af7f40cef607f0ed10cb827e/projects/sw-appcache-behavior/src/appcache-behavior-import.js#L501-L514 "Source code on GitHub") | ||
[projects/sw-appcache-behavior/src/appcache-behavior-import.js:501-514](https://github.com/GoogleChrome/sw-helpers/blob/0c15c2fde8a3f835d03d47af2075e5171af11f39/projects/sw-appcache-behavior/src/appcache-behavior-import.js#L501-L514 "Source code on GitHub") | ||
@@ -79,2 +79,2 @@ `goog.legacyAppCacheBehavior` is the main entry point to the library | ||
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).<[Response](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5)>** | ||
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Response](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5)>** |
65540
1768
8