I'd like to know if there's a general rule of thumb wheter to enable gzipping for PDF files or not. I use NGINX but I think this would be helpful for Apache users as well.
Thanks.
This is just my opinion, but I think that zip-compressing PDF files is not a good idea.
PDF files will almost always use some kind compression internally, FLATE is used in general for text content inside pages, and lossy-compression is in general used for images (PNG, JPEG, JPEG2000 are common for color images and CCITT or JBIG2 are commonly used for gray-scale and monochrome). Re-compressing your files once more will provide little gain (if any) in terms of space and it will reduce the usability of the system as a whole.
If your PDF files are mainly text based (few to no images) and your server has a lot of traffic accessing the same document and can handle the compressing , then yes, mod_deflate or mod_gzip is a good idea. If you're unsure, try it out first, and if the performance goes down, just undo it. I've been serving all content except images and video with mod_deflate for over a year now, and it's cut my bandwidth to under half (Lots of text documents and scripts). Also consider looking into a cache system if not already, as this will really reduce the workload on the server.