5.4.0f3 - Troubleshooting gzip compression

Hi all,

I’ve spent the last few days trying to improve load times on my game and I’m consistently getting the following errors in the console logs on Firefox, Safari, and Chrome across 2 different projects:

Failed to load resource: the server responded with a status of 404 (Not Found) when trying to access a .mem file (yes, .mem, not memgz the log says) from the Resources folder.

Decompressed Release/filename.memgz in 156ms. You can remove this delay if you configure your web server to host files using gzip compression.

I get decompress errors for the memgz, jsgz, and datagz files, which prompted me to start hunting a solution for enabling gzip compression on my Ubuntu 14.04 LTS x64 server running Apache2. I’ve tried (on two different servers with different configs):

  1. Editing the apache2.conf file in /etc/apache2 to include these two lines:
AddType application/octet-stream .memgz .datagz .unity3dgz
AddType application/javascript .js
  1. Adding these lines to the mime.conf file in mods-enabled:
AddType application/octet-stream .mem .data .datagz .memgz
AddType application/x-javascript .jsgz
  1. Adding these lines to the deflate.conf file in mods-enabled:
AddOutputFilterByType DEFLATE application/octet-stream
AddOutputFilterByType DEFLATE application/x-gzip
  1. Doing 1 and 2 in tandem
  2. Not doing 1 through 4 and creating an .htaccess file like below and placing it in Release
Options +SymLinksIfOwnerMatch<IfModule mod_rewrite.c>
  <IfModule mod_mime.c>

    RewriteEngine on
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}gz -f
    RewriteRule ^(.*)\.(js|data|mem|unity3d)$ $1.$2gz [L]
  
    AddEncoding gzip .jsgz
    AddEncoding gzip .datagz
    AddEncoding gzip .memgz
    AddEncoding gzip .unity3dgz

  </IfModule>
</IfModule>
  1. Trying either placing .htaccess file like below in Release or build root folder:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /var/www/html/fbcanvas_b32/
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}gz -f
RewriteRule ^(.*)\.js$ $1\.jsgz [L]

RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}gz -f
RewriteRule ^(.*)\.data$ $1\.datagz [L]

RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}gz -f
RewriteRule ^(.*)\.mem$ $1\.memgz [L]

RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}gz -f
RewriteRule ^(.*)\.unity3d$ $1\.unity3dgz [L]

AddEncoding gzip .jsgz
AddEncoding gzip .datagz
AddEncoding gzip .memgz
AddEncoding gzip .unity3dgz

In all other aspects, the games seem to play fine.

I will readily admit I’m not much of a web host admin so my knowledge on Apache is limited. I do have physical access and root access to the server so I’m down for trying out just about anything, but I’m out of ideas for how to get this working. I really don’t get why it isn’t able to server these gz files decompressed. I can provide builds, links, and apache config files.

Also, the 404 error concerns me a little when it’s looking for the .mem file. The loading seems to stall at that point and that may be contributing to load time slowness.

Excuse my derp. I have read Apache docs about 20 times but it never sticks. The .htaccess file worked just fine once I added this to my apache2 config file:

<Directory /var/www/webgl_testbed>
AllowOverrideAll
    Order Allow,Deny
    Allow from all
</Directory>

and stored my webgl build inside that folder. This also took care of the 404 error.

I guess I won’t quit my M$ sysadmin dayjob just yet.

If I wanted to set this globally for that dir, I would just put the .htaccess contents into the section of apache2 config like above? That way I don’t have to worry about individual .htaccess files in projects?

I’ve run into situations where I have for whatever reason omitted the AllowOverrideAll when it was necessary, causing a frustrating hunt for the cause of some downstream repercussion.

I think the directive does apply to subdirectories, but I’m not sure. That’s easy enough to test.

1 Like