Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-fetch the config.json to improve startup time #2790

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

sandhose
Copy link
Member

@sandhose sandhose commented Nov 15, 2024

This does three things:

  • remove the ?cachebuster from the config URL, we instead rely on having correct cache headers
  • add a link rel=preload for the config file in the index.html
  • adjust the default cache-control to use a 'stale-while-revalidate' strategy. This way, the CDN and the browser will cache the index.html and the config.json for a short time, ensuring that we always get the latest version, but still allowing us to pre-fetch the config file.

The difference is most noticeable when the assets are already cached by the browser, as loading the app is basically two requests away: one for the index.html, which immediately triggers the preload, so we don't have to wait for the JS to be parsed and executed for that.

Comparison waterfall with the app already cached in both cases:

image

Notice how the config.json is loaded way earlier, and therefore unblocks loading of other resources

Copy link
Contributor

@fkwp fkwp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sandhose sandhose merged commit d77e9e8 into livekit Nov 15, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants