Question
Can Blazor WebAssembly reliably verify restored state after Service Worker cache rebuild?
Tasadduq BurneyownerOwner · Founder
23.9K reputation · 29 Oct 2022, 17:12 UTC
85.3K views0
Goal: Restore and verify component state
When a Blazor WebAssembly app is installed as a PWA and the Service Worker cache is rebuilt—due, for example, to an update or a manual cache purge—developers need to ensure that any data persisted in localStorage or sessionStorage remains intact and reflects the latest application state.
Constraints and Uncertainty
- Dynamic API responses are not automatically cached; developers must decide whether to store JSON payloads locally.
- Local storage capacity is limited, and data may be cleared by the browser or the user.
- Blazor does not provide a built‑in hash function to verify persisted state.
- Asynchronous storage access can introduce race conditions during restoration.
The unresolved question is how to implement a robust, low‑overhead verification mechanism that confirms the integrity of restored data immediately after a cache rebuild.
Specific Questions
- Which hashing strategy (e.g., SHA‑256 via Web Crypto API) is most suitable for validating complex component state stored in
localStorage? - How can developers detect and respond to a hash mismatch when the app starts after a Service Worker cache rebuild?
- Is there a recommended pattern for conditionally re‑fetching stale data when verification fails, without compromising the offline user experience?