3

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.

pvorb
  • 980
  • 3
  • 10
  • 15

2 Answers2

4

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.

yms
  • 170
  • 9
  • 2
    +1 - A properly created PDF should already be compressed. If not, then it should be modified or redistilled unless there's some mitigating factor. (e.g. must be sent through a production workflow that doesn't support compressed streams/images inside the PDF) – afrazier Apr 17 '12 at 13:50
2

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.

U4iK_HaZe
  • 631
  • 5
  • 13