I'm sitting here using SVG, and I would like to gzip those files, using the SVGZ - The problem is, that I get this error when I open the SVGZ file:
This page contains the following errors:
error on line 1 at column 1: Encoding error Below is a rendering of the page up to the first error.
I've tried creating the same svg in different types of applications, and tried it in different browsers and even servers. I've worked with svgz before, where I could get it showing, but it was some time ago..
Anyone that knows how to fix this?
I found making sure the 'Image Location' is set to 'Embed' and NOT 'link' in the saving to SVG settings worked for me
I faced the same problem and i found the solution after some digging. My solution is for IIS but during my test i found the same behavior on Apache.
Mime type for svgz is somewhat bugged, because is the same of uncompressed SVG:
image/svg+xml
So to enable SVGZ serving on IIS i had to add a rewrite rule which added the hedaer
Content-Encoding: gzip
This was working but sometimes the browser was receiving the former encoding error.
The problem was the server treated svgz as static content, and because "static compression" was enabled on the site, the client were receiving sometimes the original content, sometimes the compressed (and cached) one, without knowing the difference because server compression act enabling the gzip Content-Encoding header, the same the rewrite rule was enabling all the times.
The client is actually unable to understand when the server re-compressed the content and when not.
The possible solutions are:
The second solution for IIS can be enabled 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 will help you.
PS: this is my first post on stackoverflow!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With