You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried using a .svg.gz file with Lektor, but it would not correctly serve this file.
The file would be served with headers
HTTP/1.1 200 OK
Server: Werkzeug/2.2.2 Python/3.11.2
Date: Wed, 15 Mar 2023 14:07:54 GMT
Content-Type: image/svg+xml; charset=utf-8
Cache-Control: no-store, public
Content-Length: 10195
ETag: "lektor-1678845790.2140253-10195-362676959"
Connection: close
but the file is still gzip compressed, i.e., without
Content-Encoding: gzip
This causes the browsers to attempt to parse the compressed data as XML, which obviously fails.
Of course I can just use .svg, and have my main web server do on the fly compression. The main reason I was looking into storing the images as .svg.gz was to be able compare transfer sizes for different formats and decide whether to store the images as .svg, .png or .webp. The .svg.gz size more accurately reflects when it is beneficial to switch to bitmap formats.
The text was updated successfully, but these errors were encountered:
I agree that the current behavior is not correct, but I'm not sure that I agree with you on what the correct behavior should be.
If the contents of foo.svg.gz were being served at URL .../foo.svg then clearly Content-Type: image/svg plus Content-Encoding: gzip is appropriate. In this case, though, the webserver is serving a request for, e.g., foo.svg.gz, not for foo.svg. I would think the correct response would be Content-Type: application/gzip with no Content-Encoding. (What if the file in question were foo.tar.gz?)
FWIW, Werkzeug's send_file (which is what is used by Flask to server files from the app's static dir) does appear to behave as you suggest.
As to your use case, specifically: if one wants to know the compressed size of a file, that can, of course, be computed without actually storing the file in compressed form. E.g.
gzip -c foo.svg | wc -c
or similar.
If, for optimization purposes, one wants to store pre-compressed data, I think that's more of a deployment issue. E.g. when using nginx's gzip_static module one would normally want both to deploy both a foo.svg (for serving clients that don't support gzip encoding) and foo.svg.gz (for those that do).
I tried using a
.svg.gz
file with Lektor, but it would not correctly serve this file.The file would be served with headers
but the file is still gzip compressed, i.e., without
This causes the browsers to attempt to parse the compressed data as XML, which obviously fails.
Of course I can just use .svg, and have my main web server do on the fly compression. The main reason I was looking into storing the images as .svg.gz was to be able compare transfer sizes for different formats and decide whether to store the images as .svg, .png or .webp. The .svg.gz size more accurately reflects when it is beneficial to switch to bitmap formats.
The text was updated successfully, but these errors were encountered: