Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I "gzip" my responses in Zend Framework?

I know that this bit of code:

<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>

will enable gzip. But, what is the correct way to apply this to all my Zend Frameworks Views and Layouts?

like image 690
Chris Laplante Avatar asked Dec 13 '22 14:12

Chris Laplante


1 Answers

Instead of gzipping from PHP (which means only your HTML generated content will be compressed), you could ask Apache to compress for you -- using its mod_deflate module.

Great advantage : it'll allow your server to compress HTML, of course... But also JS and CSS ; which means a huge gain for the users who have to download those when visiting your site.


Note : if you are not using Apache, other web-servers have equivalents of mod_deflate ;-)

like image 194
Pascal MARTIN Avatar answered Jan 03 '23 17:01

Pascal MARTIN