Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#372 closed enhancement (wontfix)

gzip_static: support for .svgz files

Reported by: Steffen Weber Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.3.x
Keywords: Cc:
uname -a:
nginx -V: nginx version: nginx/1.4.1


According to the SVG specification [1] and freedesktop's MIME database [2], compressed .svg files should use the filename extension .svgz (not .svg.gz). That conflicts with the nginx module "gzip_static" requiring filenames to end with a .gz extension.

I can think of two solutions:

1) Provide a directive "gzip_static_svgz" that can be set to "on"/"off".

2) Provide a directive "gzip_static_map" that enables specifying a map (e.g. ".svg" -> ".svgz").

[2] /usr/share/mime/packages/

Change History (8)

comment:1 by Maxim Dounin, 7 years ago

Resolution: wontfix
Status: newclosed

Support for complicated mappings looks like an overkill for me. Just provide *.svg.gz files if you want to use gzip_static, probably using symlinks if you already have matching *.svgz files.

comment:2 by Bob Tennent, 6 years ago

This is not an acceptable solution. The only browser that deals correctly with .svg.gz content is Opera (because it detects that the content is gzipped without looking for a Content-Encoding header). Yet all modern browsers render .svgz content correctly when there is a Content-Encoding: gzip header. The w3c standard reccommends that gzip-compressed SVG files have the extension ".svgz" (all lowercase) on all platforms:

comment:3 by Maxim Dounin, 6 years ago

The ticket is not about serving .svgz, but about gzip_static supporting it as an alternative to ".gz" suffix it normally uses for precompressed content. With gzip_static, you don't need .svgz at all - gzip_static will return either ".svg" or ".svg.gz" to a browser with appropriate headers, see docs. If you want to return svgz directly, there is nothing in nginx to stop you from doing this.

comment:4 by Bob Tennent, 6 years ago

With "gzip: on" in nginx.conf, I'm getting .svgz content served without Content-Encoding: gzip, whereas .svg.gz content causes most browsers to ask for an application.

comment:5 by Maxim Dounin, 6 years ago

Adding "Content-Encoding: gzip" to particular files isn't relevant to both gzip and gzip_static modules. Try add_header.

comment:6 by Bob Tennent, 6 years ago

Yes, thanks. So if I add

add_header Content-Encoding gzip;

to nginx.conf, the desired header is inserted. Now how does one restrict that behaviour to just .svgz files?

comment:7 by Bob Tennent, 6 years ago

I think I have it:

location ~ \.svgz$ { add_header Content-Encoding gzip; }

in the server configuration?

comment:8 by Maxim Dounin, 6 years ago

Yes, that's one of multiple ways to do this.
Please use mailing list for further support questions.

Note: See TracTickets for help on using tickets.