- Home /
Correctly configuring IIS7 to serve gzipped content. How.
So I did a webGL build - that finished successfully.
Now I wish to post this to my server, the content works when I try to access it through my local IIS (127.0.0.1) on my build machine (not using the gzip pipe maybe?).
However the gzipped extensions I can not figure out how to serve.
this is what I did:
1) Upload to server (I was not clear if I had to actually upload the two huge .mem and .data file in /DATA, from my reading of the rewrite rules below, "No, I do not have to" since all requests for those files will be redirected to their pre-compressed cousins. (but I did anyways to be sure) EDIT: You do NOT need to upload the huge files
2) checked that the web.config was being honoured to serve out the .mem and .data stuff
3) Imported the rules into URL rewrite via the IMPORT RULES button and double checked they were sensible. They all seemed fine - 4 rules - redirecting unzipped requests to zipped equivalents.
4) Checked that the server has dynamic and static compression installed and enabled for the domain (which it does)
5) revisited the .htaccess to see what I had missed.
It's the final bit where in the .htaccess it would have been handled by:
AddEncoding gzip .jsgz AddEncoding gzip .datagz AddEncoding gzip .memgz AddEncoding gzip .unity3dgz
I /think/ it is this bit maybe where it goes wrong. Not sure how to do this is IIS?
EDIT: Complete solution below
Many thanks.
Here is what I had scrabbled together so far
Hmm... well more digging says: That the following could have been an alternate solution for one part at least? perhaps both?
<rewrite>
<outboundRules>
<rule name="Rewrite JSGZ header" preCondition="IsJSGZ" stopProcessing="true">
<match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
<action type="Rewrite" value="gzip" />
</rule>
<rule name="Rewrite MemGZ header" preCondition="IsMemGZ" stopProcessing="true">
<match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
<action type="Rewrite" value="gzip" />
</rule>
<rule name="Rewrite DataGZ header" preCondition="IsDataGZ" stopProcessing="true">
<match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
<action type="Rewrite" value="gzip" />
</rule>
<preConditions>
<preCondition name="IsJSGZ">
<add input="{PATH_INFO}" pattern="\.jsgz$" />
</preCondition>
<preCondition name="IsMemGZ">
<add input="{PATH_INFO}" pattern="\.memgz$" />
</preCondition>
<preCondition name="IsDataGZ">
<add input="{PATH_INFO}" pattern="\.datagz$" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".jsgz" mimeType="application/x-javascript" />
<mimeMap fileExtension=".datagz" mimeType="application/octet-stream" />
<mimeMap fileExtension=".memgz" mimeType="application/octet-streamt" />
</staticContent>
I'm total guessing here. Really, are there any docs?
EDIT: found some more info
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL /games/WebGL/Compressed/UnityProgress/.jsgz
Physical Path \games\WebGL\Compressed\UnityProgress\.jsgz
Looks like the rewrite is not working as expected...
Answer by twobob · Dec 06, 2014 at 02:47 PM
the complete solution:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" enabled="true" stopProcessing="true">
<match url="(.*)Data(.*)\.js" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" ignoreCase="true" />
</conditions>
<action type="Rewrite" url="{R:1}Compressed{R:2}.jsgz" />
</rule>
<rule name="Imported Rule 2" enabled="true" stopProcessing="true">
<match url="(.*)Data(.*)\.data" ignoreCase="true" />
<action type="Rewrite" url="{R:1}Compressed{R:2}.datagz" />
<conditions>
</conditions>
</rule>
<rule name="Imported Rule 3" enabled="true" stopProcessing="true">
<match url="(.*)Data(.*)\.mem" ignoreCase="true" />
<action type="Rewrite" url="{R:1}Compressed{R:2}.memgz" />
<conditions>
</conditions>
</rule>
<rule name="Imported Rule 4" enabled="true" stopProcessing="true">
<match url="(.*)Data(.*)\.unity3d" ignoreCase="true" />
<action type="Rewrite" url="{R:1}Compressed{R:2}.unity3dgz" />
<conditions>
</conditions>
</rule>
</rules>
<outboundRules>
<!-- FIRST SETUP THE SWITCHES FOR THE RESPONSE ENCODING //-->
<rule name="Rewrite JSGZ header" preCondition="IsJSGZ" stopProcessing="false">
<match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
<action type="Rewrite" value="gzip" />
</rule>
<rule name="Rewrite MemGZ header" preCondition="IsMemGZ" stopProcessing="false">
<match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
<action type="Rewrite" value="gzip" />
</rule>
<rule name="Rewrite DataGZ header" preCondition="IsDataGZ" stopProcessing="false">
<match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
<action type="Rewrite" value="gzip" />
</rule>
<rule name="Rewrite Unity3DGZ header" preCondition="IsUnity3DGZ" stopProcessing="true">
<match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
<action type="Rewrite" value="gzip" />
</rule>
<!-- AND SETUP THE MATCHES FOR THE RESPONSE ENCODING SWITCHES //-->
<preConditions>
<preCondition name="IsJSGZ">
<add input="{PATH_INFO}" pattern="\.jsgz$" />
</preCondition>
<preCondition name="IsMemGZ">
<add input="{PATH_INFO}" pattern="\.memgz$" />
</preCondition>
<preCondition name="IsDataGZ">
<add input="{PATH_INFO}" pattern="\.datagz$" />
</preCondition>
<preCondition name="IsUnity3DGZ">
<add input="{PATH_INFO}" pattern="\.unity3dgz$" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
<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>
<urlCompression doStaticCompression="true" doDynamicCompression="false" />
</system.webServer>
</configuration>
as outlined here http://forum.unity3d.com/threads/solved-iis-configuring-it-to-serve-out-the-new-webgl-stack-files-how.284080/
thanks. Hope it helps someone else, took me all night to work it out :P
The above answer is now out of date with the advent of RC2.
The folders are called Release, Development, Compressed and TemplateData
a slight amendment should cover it I think
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="IgnoreProgressScript" stopProcessing="true">
<match url="TemplateData\/UnityProgress\.js" />
<action type="None" />
</rule>
<rule name="Imported Rule 1" enabled="true" stopProcessing="true">
<match url="(.*)Release(.*)\.js" ignoreCase="true" />
<conditions logicalGrouping="$$anonymous$$atchAll">
<add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" ignoreCase="true" />
</conditions>
<action type="Rewrite" url="{R:1}Compressed{R:2}.jsgz" />
</rule>
<rule name="Imported Rule 2" enabled="true" stopProcessing="true">
<match url="(.*)Release(.*)\.data" ignoreCase="true" />
<action type="Rewrite" url="{R:1}Compressed{R:2}.datagz" />
<conditions>
</conditions>
</rule>
<rule name="Imported Rule 3" enabled="true" stopProcessing="true">
<match url="(.*)Release(.*)\.mem" ignoreCase="true" />
<action type="Rewrite" url="{R:1}Compressed{R:2}.memgz" />
<conditions>
</conditions>
</rule>
<rule name="Imported Rule 4" enabled="true" stopProcessing="true">
<match url="(.*)Release(.*)\.unity3d" ignoreCase="true" />
<action type="Rewrite" url="{R:1}Compressed{R:2}.unity3dgz" />
<conditions>
</conditions>
</rule>
</rules>
For the opening rules probably