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

Cache support #20177

Open
Parth589 opened this issue Sep 1, 2023 · 2 comments
Open

Cache support #20177

Parth589 opened this issue Sep 1, 2023 · 2 comments

Comments

@Parth589
Copy link

Parth589 commented Sep 1, 2023

is there any way to cache the wasm file and other two worker and core files on client side? Because when user want to frequantly use the website they have to download files each time they open a new session. Is there any way to do this?

@juj
Copy link
Collaborator

juj commented Sep 1, 2023

If the wasm file is large, e.g. bigger than 5MB, then you'll need to implement manual caching using IndexedDB or OPFS - browsers have hardcoded limits for max file sizes that they cache: https://serverfault.com/questions/338722/what-is-the-maximum-file-size-that-will-be-cached-by-a-browser

If the wasm file is small enough, then the two common strategies are to use Last-Modified-Since caching or ETag caching or a hybrid of those. The client side code generated by Emscripten for this already will employ these mechanisms - you'll have to configure the server side with the appropriate Response Headers to make that work. https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching is a good starting point for caching.

@Alexufo
Copy link

Alexufo commented Mar 11, 2024

@juj IndexedDB is not recommended, I believe.
WebAssembly/spec#821

Do you have more information about the 5mb threshold?

Is service-worker the best approach to caching wasm?

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

No branches or pull requests

3 participants