Unfortunately, I’m always getting the following errors and the game does not start:
Uncaught SyntaxError: Invalid or unexpected token
at HTMLScriptElement.r.onload (output.loader.js:1)```
Screenshot:

Things look better when I activate "Decompression Fallback" in Unity's WebGL publishing settings, or if I just don't use compression. However, in this case the game only works on rather fast internet connections. Slower connections (simulated or real) always result in this error after a minute or so of loading:
```GET http://[our.server.domain]/game/Build/output.wasm.unityweb net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)```
Screenshot:

The game we develop is for schools (with usually notoriously slow internet connections), so this is rather dramatic for us.
Our webspace and server provider says GZip is enabled on our server, and that there is no timeout for downloading/streaming files.
Unity version is 2020.3.3f1.
Any help would be greatly appreciated, because I'm stuck and the projects release is due next week :( .
Well, the first part of my question (gzip) is not as important as the second part is. The game not loading on slow connections is a huge problem for us.
I seem to get a slightly better result with Unity 2021.2.0f1, where sometimes “only” the file ‘*.data.unityweb’ fails to load, but ‘*wasm.unityweb’ does load, in which case the game still runs. But most of time, loading the game still fails with ‘net:ERR_CONTENT_LENGTH_MISMATCH 200’ on slow connections, albeit with some more accompanying error messages:
Again, no problems on faster connections. Really seems to be some kind of timeout-issue. The data-package is 13.2 Mb in size, while the whole build is 22 Mb.
Most web servers, when configured to serve gzip compressed files will still expect the files placed in the directory to server to be uncompressed. The webserver will then compress each file when it serves it.
However, since the Unity WebGL build artifacts are large, this can be an inefficient load on the webserver (to compress the file on each request). So we can compress the artifacts as part of the Unity build, and this generates *.gz files when gzip compression is selected. Now, the webserver needs to be configured to expect statically compressed gzip files to serve. Therefore, the webserver shouldn’t itself (re-)compress them as gzip, but it does need to add the gzip content-encoding to the served files. This is what the server configuration in the Unity docs at Unity - Manual: Server configuration code samples configures.
The Invalid or unexpected token error above is saying that statically compressed gzip files are used, but the webserver isn’t correctly configured to add the zip content-encoding to those files. You should be able to verify this using the Network tab of the Developer Tools in your browser. If you look at the response, you should be able to check the content-encoding. So, check the webserver configuration: is the .htaccess file correct, and placed in the correct directory (next to the .gz files)? Check the server log files to see if there are any errors logged (e.g. parse errors of the .htaccess files).
Your second post refers to node.js. Are you using Apache as a webserver, or node.js as a webserver?