From the server-side optimization, the size of the text file can be greatly reduced by compressing the server, so that the speed of loading is multiplied. Currently, a more general compression method is to enable gzip compression. It sends the page that the browser requests, as well as the static resources referenced in the page, to the client in the form of a compressed package, and then completes the decompression and assembly on the client. The implementation does not care, we just have to enable the Gzip. Use the tool to detect the effect of not turning on page compression. The following steps let us specifically turn on Apache-based gzip compression support.
Implementation steps
Locate and open the httpd.conf file in the apache/conf directory
Open the Deflate_module and Headers_module modules in httpd.conf by removing the following two lines in front of them:
LoadModule Deflate_module modules/mod_deflate.so
LoadModule Headers_module modules/mod_headers.so
Add the following code at the bottom of the httpd.conf file to configure the files that need to be compressed:
<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. (?:p df|doc) $ no-gzip dont-vary
Addoutputfilterbytype DEFLATE text/html text/plain text/xml text/css
Addoutputfilterbytype DEFLATE Application/x-javascript
</IfModule>
Restart Apache Server
- 5
Use the tool to re-detect whether gzip compression is turned on. Considering the relevant ad detection mechanism, the specific gzip detection tool access address can be found in search engines.
I didn't find any information in the httpd.conf. So I copied this code into the conf, according to the above configuration, from the start of Apache after the detection or prompt No.
LoadModule Deflate_module modules/mod_deflate.so
- After Baidu query.
Open php-5 under the Phpnow file. 2. 12-win32 folder, locate Php-apache2handler. INI configuration file, open it and find zlib. Output_compression = Off, will be zlib. Output_compression = Off;zlib. Output_compression_level = 1 (Note:-1 for off PHP zlib (gzip) compression) modified to zlib. Output_compression = Onzlib. Output_compression_level = 6; then from the start Apache, and then the test results prompt is.
Phpnow Configuring gzip on Windows