How to "gzip" my answers in the Zend Framework?

I know this bit of code:

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

enable gzip. But what is the correct way to apply this to all my Zend Frameworks View and Layout s?

+4
source share
3 answers

Instead of gzipping from PHP (which means that only HTML content compressed will be compressed), you can ask Apache to compress for you - using mod_deflate .

A big advantage: this will allow your server to compress HTML, of course ... But also JS and CSS; which means a huge win for users who have to download them when visiting your site.


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

+11
source

This blog post should help you with what you need.

Queue, Concatenation and Gzipped Assets with Zend Framework

+1
source

This piece of code will still work on the Zend Framework, this is what I use. Also, you don't need to check the accept gzip header, since ob_gzhandler () still checks this.

+1
source

Source: https://habr.com/ru/post/1346988/


All Articles