Search code examples
symfony4http-compression

How to gzip compress Symfony4 http response before sending it?


I am developing a site with Symfony 4. After a test with GTmetrix, it appears that the files sent by the site are not compressed.

At the beginning I thought it should be a process made by the web server by default but after having contacted the hosting provider, they said it should be done by the code itself.

Do you have any idea of how it should be done with Symfony 4?


Solution

  • The Gzip compression is done directly by the server :

    Here there are websites where you can see how to do it depending on what server you use, Apache or nginx :

    Apache: https://knackforge.com/blog/karalmax/how-enable-gzip-compression-apache

    Nginx: https://www.digitalocean.com/community/tutorials/how-to-add-the-gzip-module-to-nginx-on-ubuntu-14-04