nginx which content types to enable compression for nginx which content types to enable compression for nginx nginx

nginx which content types to enable compression for


There is no definitive list of the file types you would want to gzip. Any file type readable as plain text (i.e. non-binary files) are able to be gzipped, and so a "definitive" list would be massive. Therefore, it ultimately depends on which file types you are actually serving, which you can check for any given file via the HTTP Content-Type header.

If you want to be doubly sure you are covering all possible MIME types for a particular extension (which I think is reasonable), Looking at this SO post, this text file contains a pretty darn exhaustive list.

It's important to note that some binary file types like .png and .pdf (even .woff) incorporate compression into the format itself and as such should not be gzipped (because doing so could produce a compressed file larger than the original). My rule of thumb is: if my code editor can't read the file as UTF-8 text, gzipping the file would not be wise (or at least it wouldn't be very efficient).

FWIW, I typically gzip the following formats (in my Apache .htaccess) on my site:

<IfModule mod_deflate.c>    AddOutputFilterByType DEFLATE text/html text/xml text/css text/javascript application/javascript application/x-javascript application/json application/xml image/svg+xml</IfModule>