Version: 2019.3
WebGL: Deploying compressed builds
Debugging and troubleshooting WebGL builds

Server configuration for WebAssembly streaming

For WebAssembly streaming compilation to work, the server needs to return .wasm files with an application/wasm MIME type (Multipurpose Internet Mail Extension). If you have compression enabled for your WebGL build, you need to add the correct Content-Encoding response header when serving the file. This is because the .wasm file that WebAssembly streaming generates is additionally compressed.

To serve WebGL builds with WebAssembly streaming correctly, use the following server configuration files:

Apache

For uncompressed builds put the following .htaccess file into your Build subfolder:

<IfModule mod_mime.c>
  AddType application/wasm .wasm
</IfModule>

For gzip-compressed builds put the following .htaccess file into your Build subfolder:

<IfModule mod_mime.c>
  AddEncoding gzip .unityweb
  AddEncoding gzip .wasm
  AddType application/wasm .wasm
</IfModule>

For Brotli-compressed builds put the following .htaccess file into your Build subfolder:

<IfModule mod_mime.c>
  AddEncoding br .unityweb
  AddEncoding br .wasm
  AddType application/wasm .wasm
</IfModule>

IIS

For uncompressed builds put the following web.config file into your Build subfolder:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".unityweb" />
            <mimeMap fileExtension=".unityweb" mimeType="application/octet-stream" />
            <remove fileExtension=".wasm" />
            <mimeMap fileExtension=".wasm" mimeType="application/wasm" />
        </staticContent>
    </system.webServer>
</configuration>

For gzip-compressed builds put the following web.config file into your Build subfolder:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".unityweb" />
            <mimeMap fileExtension=".unityweb" mimeType="application/octet-stream" />
            <remove fileExtension=".wasm" />
            <mimeMap fileExtension=".wasm" mimeType="application/wasm" />
        </staticContent>
        <rewrite>
            <outboundRules>
                <rule name="Append gzip Content-Encoding header">
                    <match serverVariable="RESPONSE_Content-Encoding" pattern=".*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" pattern="\.(unityweb|wasm)$" />
                    </conditions>
                    <action type="Rewrite" value="gzip" />
                </rule>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>

For Brotli-compressed builds put the following web.config file into your Build subfolder:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".unityweb" />
            <mimeMap fileExtension=".unityweb" mimeType="application/octet-stream" />
            <remove fileExtension=".wasm" />
            <mimeMap fileExtension=".wasm" mimeType="application/wasm" />
        </staticContent>
        <rewrite>
            <outboundRules>
                <rule name="Append br Content-Encoding header">
                    <match serverVariable="RESPONSE_Content-Encoding" pattern=".*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" pattern="\.(unityweb|wasm)$" />
                    </conditions>
                    <action type="Rewrite" value="br" />
                </rule>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>

  • WebAssembly Streaming added in 2019.2
WebGL: Deploying compressed builds
Debugging and troubleshooting WebGL builds