Full Stack Engineer Guide: Web Push Notifications (VAPID), Service Worker Caching Strategies & Offline Background Sync

Progressive Web Apps (PWAs) deliver native-grade mobile engagement without app store friction when engineered with clean Service Worker lifecycles and standard RFC 8292 VAPID Web Push notifications. As a Senior Full Stack Engineer, I have implemented Web Push and offline Service Worker caching across real-time chat platforms, transit schedulers (MRT Jakarta Schedule), and enterprise SaaS dashboards.

1. End-to-End VAPID Web Push Subscription Flow

  1. Generate ECDSA P-256 VAPID Keypair: Store the private key securely in backend Secret Manager and expose the URL-safe Base64 public key (`applicationServerKey`) to the frontend.
  2. Register Service Worker & Subscribe via `PushManager`: Convert the VAPID public key to a `Uint8Array` and call `registration.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey })` only after an explicit user gesture.
  3. Persist Subscription Endpoint & `p256dh`/`auth` Keys: Associate the browser push endpoint with the authenticated user in PostgreSQL and prune `410 Gone` subscriptions automatically when dispatching via `pywebpush`.
// TypeScript helper for converting URL-safe Base64 VAPID key to Uint8Array
export function urlBase64ToUint8Array(base64String: string): Uint8Array {
  const padding = "=".repeat((4 - (base64String.length % 4)) % 4);
  const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
  const rawData = window.atob(base64);
  const outputArray = new Uint8Array(rawData.length);
  for (let i = 0; i < rawData.length; ++i) {
    outputArray[i] = rawData.charCodeAt(i);
  }
  return outputArray;
}

2. Related Full Stack Engineering Guides


⚡ Hire Aldian Fazrihady — Senior Cloud, GCP, Backend, AI Application & Full Stack Engineer

Need production cloud architecture, GCP/AWS infrastructure, high-throughput backend systems, AI agents, or full stack web engineering? Book a 1-Day Programming Sprint for $100 USD (International Card / Apple Pay) or Rp 1,000,000 (Indonesian QRIS / Bank Virtual Account), or hire directly on Upwork:

Book $100 / Rp 1M 1-Day Sprint → Hire on Upwork (100% Job Success) →


About the Author — Hire Aldian Fazrihady (Cloud Engineer, GCP Professional Cloud Architect, GCP Professional Data Engineer, Backend, AI & Full Stack Engineer)

Aldian Fazrihady is a Top-Rated Senior Cloud Engineer, GCP Professional Cloud Architect (Google Cloud Certified), GCP Professional Data Engineer (Google Cloud Certified), Backend Engineer (Python, Django, FastAPI, Go, PostgreSQL), AI Application Engineer (LLMs, RAG, MCP, Google ADK, LangGraph), and Full Stack Engineer (React, Next.js, TypeScript) with 15+ years of production software engineering experience.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD / Rp 1.000.000) | View Live AI Portfolio | Send a Direct Message

Related Engineering Articles

Engineering Role Pillar Guides & Category Hubs