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

fix: WASM MIME type in Nginx config #1426

Merged
merged 4 commits into from
Apr 23, 2024
Merged

fix: WASM MIME type in Nginx config #1426

merged 4 commits into from
Apr 23, 2024

Conversation

rajivshah3
Copy link
Member

@rajivshah3 rajivshah3 commented Apr 23, 2024

Description of change

This PR adds a config file that will tell Nginx to send .wasm files with the Content-Type as application/wasm instead of application/octet-stream. This allows us to use streaming compilation, which may help performance with page loading. It also resolves this warning:

`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:
 TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.

Additionally, when the explorer is proxied through Cloudflare, the application/wasm also lets Cloudflare know that it can compress the WASM. In the case of the SDK WASM, Cloudflare will use Brotli to compress it from 6.3 MB to 1.8 MB, further improving the page load time.

Close #1430

Type of change

  • Bug fix (a non-breaking change which fixes an issue)
  • Enhancement (a non-breaking change which adds functionality)

How the change has been tested

  • Verified that SDK WASM loads
  • Verified that page loads without errors

Change checklist

Add an x to the boxes that are relevant to your changes, and delete any items that are not.

  • My code follows the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

@rajivshah3 rajivshah3 closed this Apr 23, 2024
@rajivshah3 rajivshah3 deleted the fix/wasm-mimetype branch April 23, 2024 03:50
@rajivshah3 rajivshah3 restored the fix/wasm-mimetype branch April 23, 2024 03:54
@rajivshah3 rajivshah3 reopened this Apr 23, 2024
@rajivshah3 rajivshah3 requested a review from shufps April 23, 2024 05:33
@rajivshah3 rajivshah3 marked this pull request as ready for review April 23, 2024 07:47
client/Dockerfile Show resolved Hide resolved
@begonaalvarezd
Copy link
Member

Approved but awaiting for @shufps approval

Copy link
Contributor

@shufps shufps left a comment

Choose a reason for hiding this comment

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

lgtm 👌

@begonaalvarezd begonaalvarezd changed the title Fix WASM MIME type in Nginx config fix: WASM MIME type in Nginx config Apr 23, 2024
@begonaalvarezd begonaalvarezd merged commit c716a8c into main Apr 23, 2024
6 checks passed
@begonaalvarezd begonaalvarezd deleted the fix/wasm-mimetype branch April 23, 2024 12:54
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.

[Task]: Fix WASM MIME type in Nginx config
3 participants