Course contentsShow
← Web Development
Lesson 2418 of 2,98243. Service Workers Deep DiveFree lesson

Precaching Static Assets

Learn which assets are ideal for precaching: app shell, core CSS/JS, fonts, and essential images.

Precaching Static Assets

What you'll learn: You'll discover exactly which static assets should be precached in your service worker for optimal offline performance.


Now that you understand how precaching works and how to build a precache manifest, the critical question becomes: what should you actually precache? Not every file on your site deserves immediate caching. Precaching the wrong assets wastes bandwidth and storage, while missing essential ones breaks the offline experience.

The Ideal Precache Candidates

App Shell Components are your top priority. These are the HTML, CSS, and JavaScript files that create your application's basic structure—the frame that loads before any dynamic content. Think of it as precaching the theater itself, not the movie being shown.

Core CSS and JavaScript files that power your main interface should always be precached. These include your main stylesheet, essential polyfills, and framework bundles. If your app can't function without a file, it belongs in the precache.

Web Fonts are excellent precache candidates because font files rarely change and cause visible layout shifts when missing. Users notice missing fonts immediately.

Essential Images like your logo, icons, and critical UI graphics should be precached. These are assets required for the app shell or primary navigation—not user-generated content or gallery images.

What NOT to Precache

Avoid precaching large media files, user-generated content, or frequently changing data. These belong in runtime caching strategies. Also skip API responses or assets that vary per user—precaching works best with assets identical for all users.

Think of precaching like packing an emergency kit: bring the essentials everyone needs, not everything you might possibly want.

Key Takeaway: Precache your app shell (HTML/CSS/JS), web fonts, and essential UI images—the minimal set of static assets needed for your app to load and function offline.