This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
60 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// [Working example](/serviceworker-cookbook/DIR-HERE/). | ||
|
||
self.addEventListener('install', function() { | ||
|
||
}); | ||
|
||
self.addEventListener('fetch', function() { | ||
|
||
}); | ||
|
||
self.addEventListener('activate', function() { | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
# API analytics | ||
# API Analytics | ||
|
||
Perform API usage logging without interfering with the UI layer by adding a service worker to gather the usage and use the sync API to upload gathered data from time to time. | ||
|
||
## Difficulty | ||
Intermediate | ||
|
||
## Use case | ||
## Use Case | ||
As a web app developer, I want to add API tracking capabilities to my web application trying to not modify client code nor server code at all. | ||
|
||
## Solution | ||
With the use of a service worker, we intercept each request of a client and send some information to a log API. | ||
|
||
## Category | ||
More than offline | ||
More than Offline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
# Fetching remote resources | ||
# Fetching Remote Resources | ||
|
||
This recipe shows 2 standard ways of loading a remote resource and one way to use service worker as a proxy middleware. | ||
|
||
There are used 3 types of remote resources - unsecure (http), secured with allow-origin header, and secured without the header. | ||
There are used 3 types of remote resources - unsecure (http), secured with `allow-origin` header, and secured without the header. | ||
|
||
## DOM Element | ||
DOM elements are loading the resources | ||
|
||
## Fetch | ||
Fetch issues a cors or no-cors request to each resource | ||
|
||
## Fetch with SW proxy | ||
Fetch on the client loads a local resource ./cookbook-proxy/{full URL} which is then translated to real URL in the service worker and forwarded to the client. | ||
## Fetch with Service Worker Proxy | ||
Fetch on the client loads a local resource `./cookbook-proxy/{full URL}` which is then translated to real URL in the service worker and forwarded to the client. | ||
|
||
## Difficulty | ||
Intermediate | ||
|
||
## Category | ||
General usage | ||
General Usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
# Render store | ||
# Render Store | ||
The recipe demonstrates one recommendation from the [NGA](https://wiki.mozilla.org/Gaia/Architecture_Proposal#Render_store). A cache containing the interpolated templates in order to avoid model fetching and render times upon successive requests. | ||
|
||
## Difficulty | ||
Intermediate | ||
|
||
## Use case | ||
## Use Case | ||
As a web app developer, I want to minimize the load time for revisited resources. | ||
|
||
## Solution | ||
Use an offline cache to store the template once it's completely rendered and use this copy upon next requests. | ||
|
||
## Category | ||
More than offline | ||
More than Offline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters