New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sw-appcache-behavior

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sw-appcache-behavior - npm Package Compare versions

Comparing version 0.0.4 to 0.0.6

.eslintrc

4

package.json
{
"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)&lt;[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)&lt;[Response](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5)>**
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc