question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SVGZ isn't served with the proper headers

See original GitHub issue

SVGZ is a file format supported by most (all?) of the image manipulation programs that support SVG. It’s nothing more than a SVG file compressed with gzip and .svgz support is generally implemented as an alias for .svg.gz files. The recommended MIME type for .svgz file is image/svg+xml, the same as .svg files. That means that browsers cannot differentiate between SVG and SVGZ based on the Content-type header alone.

jsDelivr correctly serves .svgz files with a Content-type: image/svg+xml header. However, it incorrectly treats them exactly the same way as a .svg files; It compresses them with gzip if the client announces support for it, making them unusable. The correct way to serve .svgz files would be to never compress them and always serve them with a Content-encoding: gzip header.

I understand that jsDelivr uses a multi-CDNs structure; Is that something that can be fixed at jsDelivr’s level?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MartinKolarikcommented, Sep 3, 2017

@JoshyPHP thanks for a very detailed description of the problem. Much appreciated!

We’ve just deployed a patch and loading SVGZ files from jsDelivr should now work correctly. You can verify it using the link you previously posted: https://cdn.jsdelivr.net/gh/s9e/s9e.github.io/emoji.svgz

That said, I need to point out that one of the advantages of SVGZ files over SVG you mentioned doesn’t really apply here:

on top of that compressing the files offline offers a better compression ratio than dynamically gzipped resources

Even if our origin servers respond with a gzipped content, the CDN providers are going to unzip it and then gzip it themselves on the fly (this is pretty much how any CDN/proxy server/… works).

0reactions
JoshyPHPcommented, Sep 3, 2017

Thanks for the awesome response time. I have to confess I have a limited knowledge of CDNs but I’ll definitely look into it to see if there’s anything I can do to avoid a bad recompression.

Read more comments on GitHub >

github_iconTop Results From Across the Web

svgz files served without "Content-encoding: gzip", resulting in ...
If I request sample.gz I do not need to send Content-encoding , only Content-Type: application/x-gzip If I have to add extra headers to...
Read more >
SVGZ files not served from Pyramid static view - Stack Overflow
When I remove it, Nginx serves up the SVGZ file from my Pyramid static path, but it fails to set the proper content-encoding...
Read more >
[Solved] serving svgz files - lighty labs - Lighttpd
To display an svgz image the browser needs to know it is receiving an gzip file, even if it hasn't been processed by...
Read more >
Serve SVG with the Correct Content Type - CSS-Tricks
I use AWS to serve my asset files, including the external svg file where all my images are defined. These SVGs are not...
Read more >
Does not render SVG from .svgz without Content-Encoding: gzip
wget --save-headers http://www.adobe.com/svg/demos/chart.svgz ... They should not serve svg files at Content-type: text/plain. Works in IE
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found