Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

generate-service-worker

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generate-service-worker - npm Package Compare versions

Comparing version 1.0.0 to 1.2.0

2

package.json
{
"name": "generate-service-worker",
"version": "1.0.0",
"version": "1.2.0",
"main": "index.js",

@@ -5,0 +5,0 @@ "repository": {

@@ -19,2 +19,3 @@ Generate Service Worker

cache: {
offline: true,
precache: ['/static/js/bundle-81hj9isadf973adfsh10.js'],

@@ -42,5 +43,6 @@ strategy: [{

### Caching
The `cache` key is used for defining caching strategies. The strings in `precache` will be used to prefetch assets and insert them into the cache. The regexes in `strategy.matches` are used at runtime to determine which strategy to use for a given GET request. All cached items will be removed at installation of a new service worker version. Additionally, you can use your own custom cache template by including the full path in the `template` property. We suggest forking our `templates/cache.js` file to get started and to be familiar with how variable injection works in the codebase.
The `cache` key is used for defining caching strategies. The strings in `precache` will be used to prefetch assets and insert them into the cache. The regexes in `strategy.matches` are used at runtime to determine which strategy to use for a given GET request. All cached items will be removed at installation of a new service worker version. Additionally, you can use your own custom cache template by including the full path in the `template` property. We suggest forking our `templates/cache.js` file to get started and to be familiar with how variable injection works in the codebase. If the `offline` option is set to `true`, the service worker will assume that an html response is an "App Shell". It will cache the html response and return it only in the case of a static route change while offline.
```js
const CacheType = {
offline?: boolean,
precache?: Array<string>,

@@ -47,0 +49,0 @@ strategy?: Array<StrategyType>,

@@ -55,2 +55,8 @@ /* eslint-disable no-throw-literal */

function booleanValidation(value) {
if (!value || typeof value !== 'boolean') {
throw `Value ${value} must be of type "boolean".`;
}
}
function objectValidation(value) {

@@ -89,2 +95,3 @@ if (!value || typeof value !== 'object') {

module.exports = {
boolean: withRequired(booleanValidation),
object: withRequired(objectValidation),

@@ -91,0 +98,0 @@ number: withRequired(numberValidation),

@@ -9,3 +9,3 @@ const V = require('./validate');

const CacheShape = V.shape({
offlineURL: V.string,
offline: V.boolean,
precache: V.arrayOfType(V.string),

@@ -12,0 +12,0 @@ strategy: V.arrayOfType(StrategyShape)

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