# googlechromelabs/sw-precache

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/googlechromelabs-sw-precache).**

5,190 stars · 381 forks · JavaScript · Apache-2.0 · archived

## Links

- GitHub: https://github.com/GoogleChromeLabs/sw-precache
- Homepage: https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
- awesome-repositories: https://awesome-repositories.com/repository/googlechromelabs-sw-precache.md

## Topics

`javascript` `offline` `offline-first` `progressive-web-app` `service-worker` `service-workers`

## Description

sw-precache is a service worker build tool and precaching generator that produces JavaScript code to version and store static assets. It functions as a command-line interface and node module designed to enable offline functionality and improve load times for web applications.

The project distinguishes itself by combining build-time asset discovery with a runtime caching orchestrator. It uses content-hash-based versioning to trigger updates only when file contents change and employs template-based code generation to inject custom routing rules and handler libraries into the resulting service worker.

The tool covers a broad range of caching and traffic management capabilities, including the definition of network-first or cache-first retrieval strategies. It manages network request routing by mapping URL patterns and HTTP methods to specific handlers to resolve traffic.

## Tags

### Web Development

- [Service Worker Generators](https://awesome-repositories.com/f/web-development/browser-integration-utilities/browser-infrastructure/service-worker-controls/service-worker-libraries/service-worker-generators.md) — Provides a command-line interface for generating service worker files and injecting precache manifests. ([source](https://cdn.jsdelivr.net/gh/googlechromelabs/sw-precache@master/README.md))
- [Service Worker Precaching](https://awesome-repositories.com/f/web-development/web-infrastructure-deployment/asset-management-build-tools/asset-lifecycle-orchestration/static-asset-management/service-worker-precaching.md) — Provides a build tool that generates service worker code to version and precache static assets for offline access. ([source](https://cdn.jsdelivr.net/gh/googlechromelabs/sw-precache@master/README.md))
- [Caching Orchestrators](https://awesome-repositories.com/f/web-development/background-processing-workers/persistent-background-workers/service-worker-runtimes/caching-orchestrators.md) — Provides a configuration layer for defining network request routing rules and storage strategies within a service worker.
- [Offline Web Applications](https://awesome-repositories.com/f/web-development/offline-web-applications.md) — Enables web applications to remain functional without an internet connection by storing essential files locally.
- [Request Routing](https://awesome-repositories.com/f/web-development/request-routing.md) — Matches network requests against URL patterns to determine the appropriate caching strategy or handler.
- [Installation Precaching](https://awesome-repositories.com/f/web-development/installation-precaching.md) — Downloads and stores a predefined list of essential files during the service worker installation phase. ([source](https://googlechromelabs.github.io/sw-toolbox/api.html))
- [Static Resource Cache Managers](https://awesome-repositories.com/f/web-development/static-resource-cache-managers.md) — Manages local storage by adding specific URLs to the cache or removing existing entries for static web resources. ([source](https://googlechromelabs.github.io/sw-toolbox/api.html))

### Data & Databases

- [Caching Strategies](https://awesome-repositories.com/f/data-databases/data-engineering-infrastructure/caching-performance/caching-strategies.md) — Implements logic for selecting between network-first or cache-first strategies to optimize data retrieval and load speeds. ([source](https://googlechromelabs.github.io/sw-toolbox/api.html))
- [Web Asset Caches](https://awesome-repositories.com/f/data-databases/dataset-management-tools/in-memory-caching/asset-caching/web-asset-caches.md) — Defines lists of specific files and URLs to be cached and updated via content hashing for web resources.

### Development Tools & Productivity

- [Service Worker Manifests](https://awesome-repositories.com/f/development-tools-productivity/build-tooling/asset-file-management/asset-processing-pipelines/asset-transformation-pipelines/asset-manifest-generators/service-worker-manifests.md) — Generates build-time lists of assets to automate downloading and storing resources during the service worker installation phase.
- [Progressive Web Apps](https://awesome-repositories.com/f/development-tools-productivity/progressive-web-apps.md) — Improves PWA performance by caching network requests and serving assets from local storage.
- [Build-Time Asset Processing](https://awesome-repositories.com/f/development-tools-productivity/build-time-asset-processing.md) — Scans the local file system to identify static assets required for the precache manifest during the build phase.
- [Template-Based Code Generators](https://awesome-repositories.com/f/development-tools-productivity/template-based-code-generators.md) — Produces functional service worker files by injecting configuration values into a predefined JavaScript boilerplate template.

### Networking & Communication

- [HTTP Request Routing](https://awesome-repositories.com/f/networking-communication/http-request-dispatching/http-request-routing.md) — Implements a routing system that maps URL patterns and HTTP methods to specific handlers within the service worker. ([source](https://googlechromelabs.github.io/sw-toolbox/api.html))

### Programming Languages & Runtimes

- [Build Artifact Content Hashes](https://awesome-repositories.com/f/programming-languages-runtimes/content-hashing-utilities/build-artifact-content-hashes.md) — Uses content-hash-based versioning to assign unique keys to assets, triggering updates only when file contents change.

### Software Engineering & Architecture

- [Configuration-Driven Logic](https://awesome-repositories.com/f/software-engineering-architecture/data-logic-injection/configuration-driven-logic.md) — Injects custom runtime caching rules and handler libraries into the generated service worker based on configuration settings.
