Why enable compression on the server? In fact, when compression is enabled on the server, the content of the webpage is compressed on the server and then sent to the client. After the client unzips the webpage, the webpage content is displayed. It increases the workload on the server and client, and reduces the amount of data transmitted over the network, it is a compromise solution with relatively small network bandwidth and powerful computer processing capabilities. How to enable server compression? The following describes how to enable Apache to support gzip by compressing the apahce server.
1. modify the configuration file httpd. conf of Apache.
Set the following two lines
# Loadmodule deflate_module modules/mod_deflate.so
# Loadmodule headers_module modules/mod_headers.so
Remove the # above.
2. Add the following content at the end of httpd. conf:
<Ifmodule deflate_module>
Setoutputfilter deflate
# Don't compress images and other
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) $ no-gzip dont-vary
Addoutputfilterbytype deflate text/HTML text/plain text/XML text/CSS
Addoutputfilterbytype deflate application/X-Javascript
</Ifmodule>
3. Save and restart the Apache server.