Windows Apache server opens compression and Web caching

Source: Internet
Author: User

Configuration file found: http.conf

Apache Open Compression

First, turn on the configuration, remove the # number in front of the code below
LoadModule Deflate_module modules/mod_deflate.so
LoadModule Headers_module modules/mod_headers.so

Second, add compression rules

<ifmodule deflate_module>
#必须的, like a switch, tells Apache to compress the content transferred to the browser
Setoutputfilter DEFLATE

#压缩级别, 1-9,9 is the highest
Deflatecompressionlevel 6

#不进行压缩的文件
Setenvifnocase request_uri \. (?: gif|jpe?g|png) $ no-gzip dont-vary #设置不对后缀gif, jpg,jpeg,png picture file compression
Setenvifnocase request_uri \. (?: Exe|t?gz|zip|bz2|sit|rar) $ no-gzip dont-vary #同上, is not set Exe,tgz,gz ... The files are compressed
Setenvifnocase request_uri \. (?:p df|mov|avi|mp3|mp4|rm) $ no-gzip dont-vary

#针对代理服务器的设置
<ifmodule headers_moudle>
Header Append vary user-agent
</IfModule>
</IfModule>

Apache opens Web cache

First, turn on the configuration, remove the # number in front of the code below

LoadModule Expires_module modules/mod_expires.so

Second, add the cache rule

<ifmodule expires_module>
Expiresactive on
ExpiresDefault "Access plus 1 month"
Expiresbytype text/html "Access plus 1 months"
Expiresbytype text/css "Access plus 1 months"
Expiresbytype image/gif "Access plus 1 months"
Expiresbytype image/jpeg "Access plus 1 months"
Expiresbytype image/jpg "Access plus 1 months"
Expiresbytype image/png "Access plus 1 months"
Expiresbytype Application/x-shockwave-flash "Access plus 1 months"
Expiresbytype application/x-javascript "Access plus 1 months"
Expiresbytype video/x-flv "Access plus 1 months"
</IfModule>

Windows Apache server opens compression and Web caching

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.