Nginx + php-fpm + apc … compression

alternative-php-cachegzipnginxphp-fpm

I have a VPS running nginx 1.1.19, php-fpm 5.3.10, and APC 3.1.9. The server is primarily running PHP scripts (vB, SMF, IPB) I'm also using Cloudflare as a CDN if that matters.

From what I can tell, there are 3 options for compression and I'm not sure which are redundant with each other or if they all are and which service should be handling it.

nginix has gzip, php-fpm has zlib, and the PHP scripts themselves have gzip. I feel I've seen in a lot of documentation that if a web server (nginx) is handling gzip, the PHP scripts shouldn't. Should zlib in php-fpm be enabled along with gzip or are they technically the same thing? I saw one source that said gzip/mod_deflate with zlib_compression is redundant and unnecessarily using CPU cycles, but my vB installation seems to run smoother when zlib and gzip are both enabled.

Does anyone know of the most efficient combination/arrangement of compression for this setup?

Best Answer

I'm not sure what happens if you enable compression in multiple layers, but I would enable it in the topmost layer, i.e. Nginx. This catches dynamically produced PHP content, but also static content that is served directly by Nginx. I see compression as one of the final output filters before sending the content to the client.

Related Topic