I want to make a list of MIME Types which can be compressed by gzip. The first obvious ones to includes are those which begin with "text/". Beyond that I can only add the ones off the top of my head which I know are textual, like "application/json".
Is there a list, canonical or otherwise, that I can refer to?
Maybe better is to make a list of types to not try to compress with gzip. Those would be the types that you know are already compressed. In particular, image, video, and audio types.
It is better to be inclusive than exclusive, since compressing something already compressed only impacts CPU time on the server, and has a vanishingly small effect on bandwidth. On the other hand not compressing something that can be compressed could have a big effect on bandwidth and therefore user experience. Many types could be added that aren't on your list. You'll totally miss the benefit of compressing those with a whitelist. Better to compress what you don't know about, and only not compress what you know for sure is already compressed.
If you're here looking for a list to put in your
gzip_types
for Nginx, this is a good starting point (taken from a quick scan of obviously compressable types from/etc/nginx/mime.types
):(
text/html
is always included, and should not be duplicated ingzip_types
)IANA manages the official list of Media Types
But to know which ones are textual, you'd need to consult RFCs in which they were proposed.
Here is Perl's list. Seems too small...
https://github.com/mikegrb/File-Compressible/blob/master/lib/File/Compressible.pm#L12-L27