sw-appcache-behavior
Advanced tools
Comparing version 0.0.4 to 0.0.6
{ | ||
"name": "sw-appcache-behavior", | ||
"version": "0.0.4", | ||
"version": "0.0.6", | ||
"description": "A service worker implementation of the behavior defined in a page's App Cache manifest.", | ||
@@ -21,3 +21,3 @@ "keywords": [ | ||
"bugs": "https://github.com/googlechrome/sw-helpers/issues", | ||
"homepage": "https://github.com/GoogleChrome/sw-helpers/tree/master/projects/sw-appcache-behavior" | ||
"homepage": "https://github.com/GoogleChrome/sw-helpers/tree/master/packages/sw-appcache-behavior" | ||
} |
@@ -11,3 +11,3 @@ # sw-appcache-behavior | ||
Browse sample source code in the [demo directory](https://github.com/GoogleChrome/sw-helpers/tree/master/projects/sw-appcache-behavior/demo), or | ||
Browse sample source code in the [demo directory](https://github.com/GoogleChrome/sw-helpers/tree/master/packages/sw-appcache-behavior/demo), or | ||
[try it out](https://googlechrome.github.io/sw-helpers/sw-appcache-behavior/demo/) directly. | ||
@@ -17,11 +17,19 @@ | ||
### goog.legacyAppCacheBehavior | ||
### goog.appCacheBehavior.fetch | ||
[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") | ||
[packages/sw-appcache-behavior/src/appcache-behavior-import.js:514-527](https://github.com/GoogleChrome/sw-helpers/blob/8769cb5ff7d131573fe90aafac4a6b2ba7991b41/packages/sw-appcache-behavior/src/appcache-behavior-import.js#L514-L527 "Source code on GitHub") | ||
`goog.legacyAppCacheBehavior` is the main entry point to the library | ||
`goog.appCacheBehavior.fetch` is the main entry point to the library | ||
from within service worker code. | ||
The goal of the library is to provide equivalent behavior to AppCache | ||
whenever possible. The one difference in how this library behaves compared to | ||
a native AppCache implementation is that its client-side code will attempt to | ||
fetch a fresh AppCache manifest once any cached version is older than 24 | ||
hours. This works around a | ||
[major pitfall](http://alistapart.com/article/application-cache-is-a-douchebag#section6) | ||
in the native AppCache implementation. | ||
**Important** | ||
In addition to calling `goog.legacyAppCacheBehavior` from within your | ||
In addition to calling `goog.appCacheBehavior.fetch()` from within your | ||
service worker, you _must_ add the following to each HTML document that | ||
@@ -42,3 +50,3 @@ contains an App Cache Manifest: | ||
Once you've added `<script src="path/to/client-runtime.js"></script>` to | ||
your HTML pages, you can use `goog.legacyAppCacheBehavior` within your | ||
your HTML pages, you can use `goog.appCacheBehavior.fetch` within your | ||
service worker script to get a `Response` suitable for passing to | ||
@@ -53,3 +61,3 @@ [`FetchEvent.respondWidth()`](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith): | ||
self.addEventListener('fetch', event => { | ||
event.respondWith(goog.legacyAppCacheBehavior(event).catch(error => { | ||
event.respondWith(goog.appCacheBehavior.fetch(event).catch(error => { | ||
// Fallback behavior goes here, e.g. return fetch(event.request); | ||
@@ -60,3 +68,3 @@ })); | ||
`goog.legacyAppCacheBehavior` can be selectively applied to only a subset | ||
`goog.appCacheBehavior.fetch()` can be selectively applied to only a subset | ||
of requests, to aid in the migration off of App Cache and onto a more | ||
@@ -72,5 +80,5 @@ robust service worker implementation: | ||
if (event.request.url.match(/legacyRegex/)) { | ||
event.respondWith(goog.legacyAppCacheBehavior(event)); | ||
event.respondWith(goog.appCacheBehavior.fetch(event)); | ||
} else { | ||
event.respondWith(robustServiceWorkerBehavior(event)); | ||
event.respondWith(goog.appCacheBehavior.fetch(event)); | ||
} | ||
@@ -82,4 +90,4 @@ }); | ||
- `event` **FetchEvent** | ||
- `event` **FetchEvent** | ||
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)>** |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
125866
30
2980
87
2
18