Avoid Partial Content HTTP download in webR, fixing browser caching for cairo.so
#151
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.
Github Pages supports serving content with HTTP status 206, "Partial Content", but content that is served in this way is not cached by the brower (at least, not by Chrome). So, when using Shinylive hosted on GitHub Pages multiple (slow!) network requests are sent on every page load for the webR resource file
cairo.so
, even if the file has already been previously downloaded by the browser.Emscripten is configured to fetch lazy filesystem content with size greater than 1MB in chunks, using the partial content mechanism. The chunk size is hard coded here and I can't see a way to disable things. We might be able to submit a PR to Emscripten implementing such a disable switch, but even so this would then still require upgrading Emscripten for a new release of webR, which we can't do until R 4.5.0 for ABI reasons.
For the moment, this PR patches the lazy file system mechanism to always skip partial content and download the entire file. With this,
cairo.so
is loaded in a single request, and the response is cached as expected.R package library content should not be affected, since webR uses a custom VFS mounting routine for those in any case. Also, the patch only touches webR, pyodide should not be affected in any way. AFAICT, the only file large enough in webR's base distribution to be affected in this way will be
cairo.so
itself.