Speeding up websites with simple Apache settings in Htaccess [zlib.output_compression + mod_deflate] a Syntax

Imagine these two pieces of code that are in htaccess to speed up the site.
From php 5.2.3 to apache 2.0

block A

# preserve bandwidth for PHP enabled servers <ifmodule mod_php4.c> php_value zlib.output_compression 16386 </ifmodule> 

block B

 # compress speficic filetypes <IfModule mod_deflate.c> <FilesMatch "\.(js|css|eot|ttf|svg|xml|ast|php)$"> SetOutputFilter DEFLATE </FilesMatch> </IfModule> 

Questions that arise:

Q1. Is this the right way to combine these two A + B blocks into 1 htaccess in the root?

Q2. Is it correct that the second block of B again uses |php| in mod_edflate?

+1
source share
1 answer

If mod_deflate is loaded and you can control the apache configuration, then you must let apache do the compression of the output. Performing compression in php will always be slower. Here is my recommended config for your htaccess:

 <IfModule mod_deflate.c> SetOutputFilter DEFLATE SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip </IfModule> 

I think the blacklist is more efficient in this case, since there are very few types of files that you do not want to compress. Thus, you are sure to compress everything else, even those types of files that you cannot remember to add to the white list.

+2
source

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


All Articles