fix(app): add service worker for cache-first static asset loading#27936
Open
BYK wants to merge 1 commit into
Open
fix(app): add service worker for cache-first static asset loading#27936BYK wants to merge 1 commit into
BYK wants to merge 1 commit into
Conversation
Add a service worker with three caching strategies: - Navigation (HTML): stale-while-revalidate for instant page loads - Hashed assets: cache-first (immutable Vite content-hashed filenames) - Other static files: stale-while-revalidate Add font preload link for JetBrainsMono to start download during HTML parse instead of waiting for CSS evaluation. Add font-display: swap to prevent invisible text during font download.
6 tasks
Contributor
|
The following comment was made by an LLM, it may be inaccurate: I found one related PR: PR #27934: fix(server): add Cache-Control headers to static assets This PR is closely related to #27936 as both address static asset caching performance. While #27934 focuses on server-side Cache-Control headers, #27936 adds client-side service worker caching. They may be complementary approaches to the same performance issue (#27933), or there could be overlap in their solutions. You may want to review both PRs to ensure they work together effectively. |
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.
Issue for this PR
Closes #27933, closes #19119, closes #19174
Type of change
What does this PR do?
Adds three front-end performance optimizations:
Service Worker (
public/sw.js):index.htmlinstantly while refreshing in the backgroundRegistration added to
entry.tsx— non-blocking, fire-and-forget.Font preload (
index.html):<link rel="preload">for JetBrainsMono woff2 to start download during HTML parse instead of waiting for CSS evaluation.font-display: swap (
index.css):font-display: swapto the@font-facedeclaration to prevent invisible text (FOIT) during font download.How did you verify your code works?
Tested locally: verified SW registers and caches assets on first visit, serves from cache on refresh, and updates in the background. Font loads without invisible text flash. Network tab confirms font preload starts during HTML parse.
Screenshots / recordings
N/A — performance improvement.
Checklist