SVGZ gives a coding error

I am sitting here using SVG, and I would like to gzip these files using SVGZ. The problem is that I get this error when opening the SVGZ file:

This page contains the following errors:

the error in row 1 in column 1: Encoding error The following is the page rendering before the first error.

I tried to create the same svg in different types of applications and tried it in different browsers and even servers. I used to work with svgz where I could show it, but that was some time ago.

Who knows how to fix this?

+7
source share
3 answers

It's hard to guess the information you provide, but it looks like you are sending gzipped SVG without the right set of Content-Encoding: gzip. This will cause the XML browser parser to not be able to parse the content since it will not be XML.

0
source

I found that "Image Location" is set to " enter image description here Embed 'and NOT' link 'in SVG save settings that worked for me

0
source

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!

0
source

Source: https://habr.com/ru/post/899897/


All Articles