Step 1: Check whether the following two modules are enabled in/etc/httpd/conf/httpd. conf: LoadModule
Step 1:
Check whether the following two modules are enabled in/etc/httpd/conf/httpd. conf:
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
View method:
Cat/etc/httpd/conf/httpd. conf | grep mod_deflate
Cat/etc/httpd/conf/httpd. conf | grep mod_headers
If there is # above, you need to enable and delete it!
Enabling gzip consumes additional cpu resources
Step 2:
Add the following at the end of the apache configuration file:
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI .(? : Gif | jpe? G | png) $ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(? : Exe | t? Gz | zip | bz2 | sit | rar) $ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(? : Pdf | doc | avi | mov | mp3 | rm) $ no-gzip dont-vary
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE application/x-javascript
Step 3:
Restart apache: service httpd restart
It is found that gzip is enabled, which is much faster: