docs(service-worker): minor fixes/improvements (#23339)
PR Close #23339
This commit is contained in:
parent
639d52fe71
commit
d1e716b2cb
|
@ -1,5 +1,3 @@
|
|||
{@a glob}
|
||||
|
||||
# Service worker configuration
|
||||
|
||||
#### Prerequisites
|
||||
|
@ -166,4 +164,3 @@ The Angular service worker can use either of two caching strategies for data res
|
|||
* `performance`, the default, optimizes for responses that are as fast as possible. If a resource exists in the cache, the cached version is used. This allows for some staleness, depending on the `maxAge`, in exchange for better performance. This is suitable for resources that don't change often; for example, user avatar images.
|
||||
|
||||
* `freshness` optimizes for currency of data, preferentially fetching requested data from the network. Only if the network times out, according to `timeout`, does the request fall back to the cache. This is useful for resources that change frequently; for example, account balances.
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ caching an invalid resource. In a normal HTTP cache, a hard refresh
|
|||
or cache expiration limits the negative effects of caching an invalid
|
||||
file. A service worker ignores such constraints and effectively long
|
||||
caches the entire app. Consequently, it is essential that the service worker
|
||||
get the correct content.
|
||||
gets the correct content.
|
||||
|
||||
To ensure resource integrity, the Angular service worker validates
|
||||
the hashes of all resources for which it has a hash. Typically for
|
||||
|
@ -298,7 +298,7 @@ design attempts to minimize the impact of such problems, the
|
|||
Angular service worker contains several failsafe mechanisms in case
|
||||
an administrator ever needs to deactivate the service worker quickly.
|
||||
|
||||
## Fail-safe
|
||||
### Fail-safe
|
||||
|
||||
To deactivate the service worker, remove or rename the
|
||||
`ngsw-config.json` file. When the service worker's request
|
||||
|
|
|
@ -99,11 +99,10 @@ using an example application.
|
|||
|
||||
Because `ng serve` does not work with service workers, you must use a separate HTTP server to test your project locally. You can use any HTTP server. The example below uses the [http-server](https://www.npmjs.com/package/http-server) package from npm. To reduce the possibility of conflicts, test on a dedicated port.
|
||||
|
||||
To serve with `http-server`, change to the directory containing your web files and start the web server:
|
||||
To serve the app, start `http-server` and specify the directory containing your web files and the port:
|
||||
|
||||
```sh
|
||||
cd dist
|
||||
http-server -p 8080
|
||||
http-server dist -p 8080
|
||||
```
|
||||
|
||||
### Initial load
|
||||
|
@ -169,8 +168,7 @@ next step is understanding how updates work.
|
|||
|
||||
```sh
|
||||
ng build --prod
|
||||
cd dist
|
||||
http-server -p 8080
|
||||
http-server dist -p 8080
|
||||
```
|
||||
|
||||
### Updating your application in the browser
|
||||
|
|
Loading…
Reference in New Issue