For Windows version apache2.2, open the method as follows:
First step:
Locate the Apache configuration file httpd.conf, find the following two lines and remove the front #. HTML code LoadModule deflate_module modules/mod_deflate.so LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule expires_module modules/mod_expires.so
Reboot the Apache server.
Step Two:
Open the. htaccess file of your Web site and copy the following code: HTML code<ifmoduleMod_expires.c> expiresactive on expiresdefault "Access plus 12 month" expiresbytype text/html "Access plus 12 months" expiresbytype text/css "access plus 12 months" expiresbytype image/gif "access plus 12 months " expiresbytype image/jpeg " access plus 12 Months " expiresbytype image/jpg " Access plus 12 months " expiresbytype image/png "Access plus 12 months" expiresbytype application/x-shockwave-flash "Access plus 12 months" expiresbytype application/x-javascript "Access plus 12 months" expiresbytype video/x-flv "Access plus 12 months" </IfModule><ifmoduleMod_deflate.c>Setoutputfilter DEFLATE addoutputfilterbytype DEFLATE text/html text/css image/gif image/jpeg image/png application/x-j Avascript</IfModule>
<ifmodule mod_expires.c>
expiresactive on
expiresdefault "Access plus month"
Expiresbytype HTML "Access plus months"
expiresbytype text/css "Access plus months"
expiresbytype image/gif "Access plus 1 2 months "
expiresbytype image/jpeg" Access plus months "
expiresbytype image/jpg" Access plus months "
Ex Piresbytype image/png "Access plus months"
expiresbytype application/x-shockwave-flash "Access plus months"
expiresbytype application/x-javascript "Access plus months"
expiresbytype video/x-flv "Access plus 12 Months "
</IfModule>
<ifmodule mod_deflate.c>
setoutputfilter deflate
Addoutputfilterbytype DEFLATE text/html text/css image/gif image/jpeg image/png application/x-javascript </
Ifmodule>
The code is correct, the test passed, we can rest assured that the use.
Explain. Expiresbytype is the MIME type to set the cache time of the specific file, a is accessed, and a number after it represents the cached time after the access. Addoutputfilterbytype means to compress files based on the MIME type that follows, where gzip compression is performed on Css,html,gif,jpeg,png,javascript. For more options, please refer to the Apache manual.
Close ETag. The problem with ETag is that it is generated based on the unique properties of the server on which the site resides. When a browser obtains page content from a server and authenticates to another server, the ETag does not match, which is very common for Web sites that use server groups and process requests. Write the following line in the configuration file:
Fileetag None
If it is a multiple server load balancing, it can be set to Fileetag mtime size,apache default setting is Fileetag inode mtime Size, remove Inode.
The
effect is as follows:
URL http://www.k686.com/Detection results are as follows:
Compression is a
compression type gzip
Original file size 91844 bytes
Compressed file size 15365 bytes
Compression rate (estimated) 83.27%
Header information
Date Thu June 09:00:14 GMT
Server apache/2.2.11 (Win32) php/5.2.10
X -powered-by php/5.2.10
Set-cookie phpsessid=nkcqphhqt8005prgnn35fdfif4; path=/
Expires Thu, Nov 1981 08:52:00 GMT
Cache-control Private
Pragma no-cache
Vary accept-encoding
content-encoding gzip
Content-length 15365
keep-alive timeout=5, max=100
Connection keep-alive
Content-type text/html; charset=utf-8