PWA v4.1.6 - Sophia - Deprecated Technical Documentation
| Document type | Archived technical reference |
|---|---|
| Applies to | service-worker.js v4.1.6, register-pwa.js (older revision) |
| Entity | Clickerwayne Zelle Solutions Inc |
| Site | https://www.wholesaledito.store |
| Status | Deprecated. Superseded by v6.0.0 |
| Last reviewed | September 14, 2026 |
Overview
PWA v4.1.6 was the Progressive Web App layer active on Wholesale Dito Store before the v6 rewrite. It provided offline caching, a basic product fallback, and a catalog sync that ran on install and on demand.
The version was built around a smaller set of constraints than v6. It prioritized minimal code size over resilience. It did not include circuit breakers, multi-tab locking, or detailed error telemetry.
The service worker did not use generative AI. All caching, syncing, and fallback behavior was deterministic code.
What changed in v6
The v6 rewrite added several capabilities that were not present in v4.1.6. This table summarizes the difference between the two versions.
| Feature | v4.1.6 | v6.0.0 |
|---|---|---|
| Configuration object | Inline constants | Single CONFIG object |
| Cache names | Hardcoded prefix | Derived from APP_NAME and SW_VERSION |
| Circuit breakers | Not present | Two circuits, half-open state, IDB persisted |
| Network heuristics | Not present | Latency and failure tracking over 30s window |
| Error logging | Console only | Three-tier: IDB, postMessage, console |
| IDB transaction safety | Raw transactions | Retry with backoff, synchronous listener attachment |
| DB recovery | None | Three-tier: normal, recovery, fresh suffix |
| Multi-tab safety | None | Web Locks and onversionchange |
| Image in-flight dedupe | Basic map, no eviction | Bounded map with FIFO eviction |
| Telemetry batching | Timer, best-effort write | Dirty flag, batched flush, persisted |
| Catalog sync rate limits | 10 minute lockout after success | Attempt window, failure backoff, stuck detection |
| Maintenance | None | Periodic reconciliation, metadata cleanup |
| Periodic background sync | Not registered | Registered when supported |
| Version migration | Implicit cache delete | Explicit migration with IDB cleanup |
Architecture (v4.1.6)
The v4.1.6 service worker was organized into four layers:
| Layer | Responsibility |
|---|---|
| Constants | Version, cache names, timing values, precache arrays |
| Storage | Three IndexedDB databases, three Cache Storage buckets |
| Handlers | Product, navigation, API, image, static |
| Lifecycle | Install, activate, fetch, sync, message, push, notificationclick |
Unlike v6, there was no separate routing layer. Each handler was called directly from a chain of if checks inside the fetch event. This was simpler but harder to extend.
Storage locations
Cache Storage
| Cache name | Purpose |
|---|---|
wholesaledito-v4.1.6 | Precache of critical assets |
wholesaledito-runtime-v4.1.6 | Navigation, API, static, image runtime cache |
wholesaledito-product-html-v4.1.6 | Cached product HTML pages |
IndexedDB
| Database | Stores |
|---|---|
wholesaledito-api-v4.1.6 | responses - cached API responses |
wholesaledito-catalog-v4.1.6 | products - offline product catalog |
wholesaledito-meta-v4.1.6 | meta - telemetry state |
Configuration constants
Configuration was defined inline as top-level constants. There was no CONFIG object.
| Constant | Value | Purpose |
|---|---|---|
SW_VERSION | 4.1.6 | Service worker version, embedded in all cache names |
CACHE_MAX_AGE | 24 hours | Max age for navigation and API cache |
PRODUCT_HTML_MAX_AGE | 7 days | Max age for cached product HTML |
QUOTA_THRESHOLD | 0.8 | Storage usage threshold for cache reduction |
NETWORK_TIMEOUT | 5000 ms | Fetch timeout |
MAX_IMAGES_CACHE | 1000 | Max images in runtime cache |
MAX_CATALOG_PRODUCTS | 2000 | Max products in offline catalog |
BATCH_SIZE | 20 | IDB write batch size |
TELEMETRY_BATCH_INTERVAL | 10000 ms | Delay before flushing telemetry |
Caching strategy by route
| Route | Strategy | Cache | Fallback |
|---|---|---|---|
RSS (/rss/*) | Network only | None | Browser error |
Product (/product/*) | Cache first, network fallback | product-html | Catalog DB, then /offline.html |
| Navigation (any HTML page) | Cache first, then network | runtime | /offline.html |
API (/sophia/api/*) | Cache first, network fallback | runtime + API DB | { offline: true } JSON |
Image (.webp, .png, .jpg, .svg) | Cache first, revalidate | runtime | offline-image-fallback.webp, then inline SVG |
| Static (everything else) | Cache first, then network | runtime | Browser error |
Compared to v6, v4.1.6 did not use stale-while-revalidate for navigation. It served from cache if present, otherwise fetched. This made cache misses slower but reduced background work.
Offline behavior
When the user is online
The service worker served cached content if available. If not cached, it fetched from the network and cached the response.
When the user goes offline
Cached pages loaded from cache. Product pages fell back to catalog data stored in IndexedDB. Uncached navigation routes fell back to /offline.html. Images that were not cached fell back to a placeholder image, then to an inline SVG.
Limitations
- No stale-while-revalidate. Cached pages did not update in the background.
- No offline badge on cached product pages rendered from the catalog.
- No "Back to Last Page" behavior. The offline page used browser history only.
- No cross-tab safety. Opening the site in multiple tabs during a version change could cause the older tab to lose its database connection without warning.
Catalog sync
The offline catalog was synced from /sophia/api/offline-catalog.php. The response format matched the shape used by v6:
{
"products": [ ... ],
"synced_at": "2026-...",
"total_count": 2000
} Each product had these fields:
| Field | Type | Used for |
|---|---|---|
uri | string | IndexedDB key, image URL slug |
productname | string | Page title, heading |
PCPRICE | number | Piece price display |
CSPRICE | number | Case price display |
STOCKS | integer | Stock badge |
brand | string | Brand badge |
description | string | Short description |
moq | integer | Minimum order quantity |
ivarid | string | Unit label |
Sync triggers
Catalog sync ran on:
- The
activateevent, once per service worker installation. - The
syncevent with the tagcatalog-sync. - The
SYNC_CATALOGmessage from a client.
Sync rate limits
- Minimum 10 minutes between successful syncs.
- No failure backoff. A failing endpoint was retried on each trigger.
- No stuck detection. If a sync hung,
isSyncingstayedtrueuntil the worker restarted.
Telemetry
Telemetry tracked five counters:
| Counter | Description |
|---|---|
cacheHits | Product HTML served from cache within max age |
cacheMisses | Product HTML not found or expired |
offlineFallbacks | Product pages served from catalog DB or offline page |
apiFailures | API requests that failed to fetch |
imageFallbacks | Images served from fallback instead of network |
Telemetry was held in memory and flushed to IndexedDB on a 10-second timer, or on the PAGE_HIDDEN message. Unlike v6, it was not persisted on every counter change, so a service worker crash could lose up to 10 seconds of counters.
Known issues in v4.1.6
The following issues were present in v4.1.6 and were addressed in v6:
| Issue | Impact | Fixed in |
|---|---|---|
| No multi-tab safety | Version change while multiple tabs open could leave a tab with a dead DB connection | v6.0.0 |
| No circuit breakers | Failing endpoints were retried on every request | v6.0.0 |
| No stuck sync detection | A hung sync set isSyncing = true until the worker restarted | v6.0.0 |
| No error persistence beyond console | Errors disappeared on page reload | v6.0.0 |
| Telemetry batching could lose counters | Up to 10 seconds of counters lost on crash | v6.0.0 |
| Image in-flight map was unbounded | Many parallel image requests could grow the map without limit | v6.0.0 |
| No stale-while-revalidate for navigation | Cached pages did not update until evicted | v6.0.0 |
| No offline product badge | Cached product pages did not signal offline state clearly | v6.0.0 |
| No "Back to Last Page" on offline page | Offline page fell back to browser history only | v6.0.0 |
| No periodic sync registration | Maintenance ran only on user interaction | v6.0.0 |
Verifying v4.1.6 (historical)
To verify that v4.1.6 was active, these were the checks:
In the browser console
Catalog synced: 2000
Service Worker v4.1.6 initialized In DevTools
Application, Service Workers:
- Status showed "activated and is running"
- Scope was
https://www.wholesaledito.store/
Application, Cache Storage:
- Three caches ending in
-v4.1.6were present
Application, IndexedDB:
- Three databases ending in
-v4.1.6were present - The catalog database held products after the first sync
Migration from v4.1.6 to v6.0.0
Upgrading from v4.1.6 to v6.0.0 required no user action. The v6 service worker handled the upgrade in its install and activate events.
What happened during migration:
- The browser detected the new
service-worker.jsfile. - The v6 install event ran: it opened three new IndexedDB databases with
-v6.0.0suffixes. - The v6 activate event deleted all caches whose names started with
wholesaledito-but were not in the current valid set. This removed the-v4.1.6caches. - Old IndexedDB databases from v4.1.6 were orphaned. They were not deleted automatically by v4.1.6 but were cleaned up by the v6 migration routine.
- The v6 service worker ran its precache and took control of open clients.
Any user who had the site open during the version change was migrated on their next page load, or when the tab was closed and reopened.
What this documentation does not cover
- How the v4.1.6 registration script handled feature detection (it did not)
- How the v4.1.6 offline page stored the last visited URL (it did not)
- How the v4.1.6 catalog endpoint differed from v6
- Any behavior that was added after v4.1.6 and before v6.0.0
This document describes only what v4.1.6 contained. For the current implementation, see the v6.0.0 documentation.
Revision history
| Date | Change |
|---|---|
| September 14, 2026 | Initial archived documentation for v4.1.6 |
Contact
For questions about this archived documentation, contact the developer at Clickerwayne Zelle Solutions Inc.