WebGL: Fix incorrect header check error when loading Content-Encoding: gzip files
Hi all,
I've struggled with this for a while now and have just about given up, but I thought I'd see if the community has found a workaround just in case.
When trying to host a Unity WebGL canvas build, I've found that the Unity-generated Release/.datagz file can quickly get so big that it needs to be loaded from its own special source, due to hosting company requirements. This causes me to have to edit the Unity index.html such that the "Module" object includes the following:
dataUrl: "https://remote.server.com/<projname>.data",
codeUrl: "Release/<projname>.js",
memUrl: "Release/<projname>.mem"
This works great... until I try to speed things up by setting the Content-Encoding on that remote object to "gzip", as instructed by the javascript warnings. That causes Unity to immediately crash on load, spitting out the "Incorrect header check" error in the title.
I've now tried this with the .datagz file on two different cloud providers, and I get the same behavior.
Unity Answers - how can I get my files hosted with gzip Content-Encoding without receiving this error?
Answer by Bryan-Legend · Nov 18, 2016 at 12:24 AM
If you're hosting on IIS use this web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".mem" mimeType="application/octet-stream" />
<mimeMap fileExtension=".data" mimeType="application/octet-stream" />
<mimeMap fileExtension=".memgz" mimeType="application/octet-stream" />
<mimeMap fileExtension=".datagz" mimeType="application/octet-stream" />
<mimeMap fileExtension=".unity3dgz" mimeType="application/octet-stream" />
<mimeMap fileExtension=".jsgz" mimeType="application/x-javascript; charset=UTF-8" />
</staticContent>
</system.webServer>
</configuration>
This was exactly what I needed for $$anonymous$$e to work. Thank you very much.
Answer by HuEdOut · Jan 09, 2017 at 10:56 AM
It sounds like a simple issue, but have you checked the file/folder name? I got the same error message on my localhost just previewing my build. It turns out that JavaScript does not like spaces in the name.
Got the same issue and after removing the spaces in my folder name it worked. Thank you!
Answer by ivank · Jun 20, 2016 at 11:52 AM
@samuel.levine I am not sure, but maybe this answer could help a little: http://forum.unity3d.com/threads/webgl-incorrect-header-check-bug-again-in-latest-beta.411725/
Your answer
Follow this Question
Related Questions
Didn't loading facebook instant game 0 Answers
WebGL Build don't work 0 Answers
the latest version of unity physics? 0 Answers
WebGL build failing Unity v5.2 0 Answers
Cannot Export to WebGL because of il2CPP stops working. 2 Answers