If you are using Apache httpd, then this is pretty simple. Just include the mod_deflate module in httpd.conf and add the AddOutputFilterByType lines for different types (more details here: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html ). I do not believe that symfony2 can gzip something by itself, since this is usually work for a web server.
source share