Skip to main content

Enabling Gzip Compression of PHP, CSS, and JS Files Without mod_deflate

By July 5, 2016August 5th, 2017PHP

For enable Gzip compression using mod_deflate add following lines to your .htaccess file AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript But those who don’t allow the mod_deflate module and run PHP in CGI/FastCGI mode you can’t go with the easy method. So, to serve up your PHP, CSS, and JS files you can try the following method.

Step 1: PHP Configuration Add or modify the following lines in your custom php.ini file

Now this will take care of gzipping all PHP files. Step 2: .htaccess Configuration Add the following lines to the bottom of a .htaccess file in the root of your website.