r/blazedotdev

Notes on building a Local-First PWA with IndexedDB and Server-Sent Events (SSE)
▲ 29 r/blazedotdev+3 crossposts

Notes on building a Local-First PWA with IndexedDB and Server-Sent Events (SSE)

When building a dealership inventory catalog for sales agents on showroom iPads, we realized standard network-on-every-filter setups were breaking the pace of sales conversations. Every loading spinner broke conversational flow.

We restructured the catalog around a local-first pattern: load the inventory once, keep it on the device, filter in memory, and use a light server signal to invalidate cache only when the inventory actually changes.

  1. Upfront Payload for In-Memory Filtering: Instead of paginated API queries on every filter change (brand, price, mileage), we fetch the full vehicle inventory once.

  2. Instant Rehydration via IndexedDB: To avoid startup latency on repeat visits, we persist the TanStack Query cache to IndexedDB.

  3. Cheap Real-Time Invalidation via RxJS + SSE: To prevent stale data (e.g., sold/repriced cars) without burning serverless budget on polling, we use a single Server-Sent Events (SSE) connection.

Read the full article: https://blaze64.dev/logs/local-first-pwa

blaze64.dev
u/Agreeable_Ad_3924 — 1 day ago