I ran into the same problem and I found a solution after some digging. My solution is for IIS, but during the test I found the same behavior on Apache.
The MIME type for svgz is somewhat erroneous because it is the same as the uncompressed SVG:
image/svg+xml
Thus, in order to enable SVGZ service on IIS, I had to add a rewrite rule that added a header
Content-Encoding: gzip
This worked, but sometimes the browser received a previous encoding error.
The problem was that the server viewed svgz as static content, and since "static compression" was enabled on the site, the client sometimes received the original content, sometimes compressed (and cached), without knowing the difference, since enabling server compression was gzip Content-Encoding header The same rewrite rule has been enabled all the time.
The client cannot actually understand when the server has re-compressed the content, and when not.
Possible solutions:
- disable static compression altogether
- disable static MIME Mapping for MIME image / svg + xml image. This will also disable compression for svg, but if your site only runs svgz, that won't be a problem.
A second solution for IIS can be enabled by editing applicationHost.config:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"> <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" /> <staticTypes> <...> <add mimeType="image/svg+xml" enabled="false" /> </staticTypes> </httpCompression>
Hope this helps you.
PS: this is my first post on stackoverflow!
source share