fix: use network-first for navigation to prevent stale HTML/MIME errors#33
Merged
brianorwhatever merged 1 commit intomainfrom Feb 7, 2026
Merged
Conversation
The previous fix (PR #23) stopped caching hashed assets, but the root issue remained: cached index.html still references old asset hashes. When user visits with stale cached HTML: 1. Cached HTML references old hashes (e.g., index-abc123.js) 2. New deploy has different hashes (e.g., index-xyz456.js) 3. Browser loads old HTML → requests old JS → 404 → HTML response 4. Browser fails with 'text/html is not a valid JavaScript MIME type' Changes: - Network-first for navigation requests (HTML always fresh from server) - Fallback to cache only when offline - Cache version bump to lisa-v3 to clear old caches - Add stale asset detection that auto-refreshes on MIME errors - Add updateViaCache: 'none' to force SW update checks - Periodic SW update checks every 5 minutes - Handle controllerchange to auto-reload on SW update This ensures users always get fresh HTML with correct asset references, while still supporting offline access as a fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
text/html is not a valid JavaScript MIME typeerror keeps happening even after PR #23.Root Cause Analysis
PR #23 correctly stopped caching hashed assets, BUT the cached index.html still references old asset hashes:
/(index.html with<script src="/assets/index-abc123.js">)index-xyz456.jsindex-abc123.js→ 404 → SPA fallback returns HTML'text/html' is not a valid JavaScript MIME typeSolution
Network-first for navigation requests - ensures users always get fresh HTML.
Changes to service-worker.ts:
lisa-v3to clear old cachesChanges to sw-registration.ts:
updateViaCache: 'none'forces SW update checks on every page loadcontrollerchange(when new SW activates)Testing
Breaking Changes
None. Users with old SWs will either:
Fixes the persistent MIME type error issue.