Progressive Web Apps | Sheetly Cheat Sheet

Last Updated: November 21, 2025

Progressive Web Apps

Build installable web applications

PWA Requirements

  • HTTPS (required for service workers)
  • Web app manifest (manifest.json)
  • Service worker for offline functionality
  • Responsive design
  • Fast and reliable performance
  • Installable (add to home screen)

Web App Manifest

{
  "name": "My PWA App",
  "short_name": "MyApp",
  "description": "A Progressive Web App",
  "start_url": "/",
  "display": "standalone",
  "background_color": "#ffffff",
  "theme_color": "#2196F3",
  "icons": [
    {
      "src": "/icons/icon-192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "/icons/icon-512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ]
}

<!-- Link in HTML -->
<link rel="manifest" href="/manifest.json">

Service Worker Basics

// Register service worker
if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/sw.js')
    .then(reg => console.log('SW registered', reg))
    .catch(err => console.log('SW error', err));
}

// sw.js - Cache resources
const CACHE_NAME = 'v1';
const urlsToCache = ['/', '/styles.css', '/script.js'];

self.addEventListener('install', event => {
  event.waitUntil(
    caches.open(CACHE_NAME)
      .then(cache => cache.addAll(urlsToCache))
  );
});

self.addEventListener('fetch', event => {
  event.respondWith(
    caches.match(event.request)
      .then(response => response || fetch(event.request))
  );
});

Caching Strategies

Item Description
Cache First Serve from cache, fallback to network
Network First Try network, fallback to cache
Cache Only Only serve from cache
Network Only Only use network
Stale While Revalidate Serve cache, update in background

Install Prompt

let deferredPrompt;

window.addEventListener('beforeinstallprompt', (e) => {
  e.preventDefault();
  deferredPrompt = e;
  
  // Show custom install button
  showInstallButton();
});

installButton.addEventListener('click', async () => {
  if (deferredPrompt) {
    deferredPrompt.prompt();
    const { outcome } = await deferredPrompt.userChoice;
    console.log(`User response: ${outcome}`);
    deferredPrompt = null;
  }
});

💡 Pro Tips

Quick Reference

Test PWAs with Lighthouse in Chrome DevTools

← Back to Data Science & ML | Browse all categories | View all cheat sheets