IIS starts with gzip and XCache and quickly

Source: Internet
Author: User
Tags zend metabase
I. Summary

This article summarizes how to enable gzip compression for Web sites that are hosted by IIS, thereby reducing the network transmission size of your Web page and increasing the speed at which users can display pages.

two. Preface.

The knowledge points of this paper are collected from the Internet, mainly from Chinese wiki. Gzip is critical when using YSlow to detect which optimizations are enabled on the Web site. Starting GIP compression will instantly reduce the network transmission size of the page.

three. HTTP Compression overview

HTTP compression is a way to transfer compressed text content between a Web server and a browser. HTTP compression uses a common compression algorithm such as gzip compression HTML, JavaScript, or CSS files. The biggest benefit of compression is that it reduces the amount of data transferred by the network, thereby increasing the access speed of the client browser. Of course, it will also add a little bit of server burden. Gzip is a more common kind of HTTP compression algorithm.

Four. HTTP Compression working principle

The Web server works with HTTP compression as follows:

After the 1.WEB server receives the HTTP request from the browser, check to see if the browser supports HTTP compression;
In the HTTP header where the user's browser sends the request, the "accept-encoding:gzip, deflate" parameter indicates that the gzip and deflate two compression algorithms are supported.

2. If the browser supports HTTP compression, the Web server checks the suffix name of the request file;
Both the static file and the dynamic file suffix startup need to be set in MetaBase.xml.
Static files need to be set: HcFileExtensions Metabase Property (click Jump to MSDN Description)
Dynamic files need to be set: HcScriptFileExtensions Metabase Property (click Jump to MSDN Description)

3. If the request file is a static file such as HTML, CSS, and the file suffix is compressed, the Web server checks the compressed buffer directory to see if the requested file has the latest compressed file;

4. If the compressed file of the requested file does not exist, the Web server returns the uncompressed request file to the browser and holds the compressed file of the request file in the compressed buffer directory;

5. If the latest compressed file of the request file already exists, then directly returns the compressed file of the request file;

6. If the request file is an ASPX dynamic file and the file suffix has compression enabled, the Web server dynamically compresses the content and returns to the browser, and the compressed content is not stored in the compressed cache directory.

Five. Enable HTTP compression in IIS

IIS does not support HTTP compression by default, and requires a simple configuration

1. Open Internet Information Services (IIS) Manager, right-click Web site-> properties, and select Services. In the HTTP Compression box, select Compress application files and compress static files, and set the maximum limit for temporary directories and temporary directories as needed;

2. Reminder: After testing this step on my machine has no effect, you can ignore. &NBSP
in Internet Information Services (IIS) Manager, right-click Web Service Extensions-> add a new Web service extension ..., and in the new Web service extension box, enter the extension "HTTP Compression" and add "required files" as C:\WINDOWS\system32\inetsrv\gzip.dll, where the WINDOWS system directory may be different depending on your installation, and select the set extension status to allow ";  
 

3. Use a text editor to open C:\Windows\System32\inetsrv\MetaBase.xml (recommended backup first),  
Find location = "/lm/w3svc/filters/ Compression/gzip is used to set gzip compression,  
Find location = "/lm/w3svc/filters/compression/deflate" for setting deflate compression . 
The top two nodes are next to each other. And the properties set are the same. &NBSP

Set HcDoDynamicCompression to TRUE if you need to compress dynamic files. Add the name of the dynamic file suffix you want to compress in hcscriptfileextensions, such as ASPX, and if you need to compress static files, set HcDoStaticCompression and HcDoOnDemandCompression to " TRUE, and add the static file suffix names you want to compress in hcfileextensions, such as XML, CSS, etc. hcdynamiccompressionlevel and hcondemandcomplevel indicate the desired compression rate. The value is 0-10, the default is 0.&NBSP
HcDynamicCompressionLevel Property Description: HcDynamicCompressionLevel Metabase property 
HcOnDemandCompLevel Property Description: HcOnDemandCompLevel Metabase property 

Description: These two property values are generally recommended to be set to 9, with the best price/performance. But in my window On Server 2003, the compression rate is the same size as the jquery and jquery ui two files (58k/188k), regardless of the setting. (20k/45k).  &NBSP

The following is my example:

<iiscompressionscheme Location = "/lm/w3svc/filters/compression/deflate" hccompressiondll= "%windir%\system32\
        Inetsrv\gzip.dll "hccreateflags=" 0 "hcdodynamiccompression=" true "hcdoondemandcompression=" true "
                     Hcdostaticcompression= "true" hcdynamiccompressionlevel= "9" hcfileextensions= htm
                     HTML txt js CSS swf XML "hcondemandcomplevel=" 9 "hcpriority=" 1 "hcscriptfileextensions=" ASP
aspx dll EXE "> </IIsCompressionScheme> <iiscompressionscheme Location ="/lm/w3 Svc/filters/compression/gzip "hccompressiondll="%windir%\system32\inetsrv\gzip.dll "HcCreateFlags=" 1 " Hcdodynamiccompression= "true" hcdoondemandcompression= "true" hcdostaticcompression= "true" Hcdy Namiccompressionlevel= "9" hcfileextensions= "htm HTML txt JS CSS swf xml "hcondemandcomplevel=" 9 hcpriority= "1" hcscriptfileextensions= ASP
aspx dll exe > </IIsCompressionScheme>

4. Save the MetaBase.xml file after editing; If the file cannot be saved, it may be in use by IIS. Open the "Start"-> "Administrative Tools"-> "services", Stop the "IIS Admin service", you can save;

5. Finally, restart IIS. You can verify the results on the HTTP compression test site. In jquery, for example, the core class library and UI class libraries are 57k and 188k in size, respectively, 20k and 45k after compression:

We use the HTTP header: Content-encoding:gzip property to determine that the returned data has enabled gzip compression:

With YSlow detection, when only static file compression is started, gzip compression is rated B:

When dynamic file compression is started at the same time, gzip compression is rated A:
Six. Summary of key points

1. When modifying the MetaBase.xml file, stop the "IIS Admin Service" service. Otherwise, it cannot be saved.

2. Static compression and dynamic compression rates are best set to 9.

3. Step 2 above is the same even if the Web service extension effect is not added.

4. Compression rate settings on the JS file does not work, after compression is always the same size.

5. The picture file does not change even if the gzip compression size is enabled. Seven. Summary

This article summarizes how to enable gzip compression in IIS. In the project of six months ago I enabled Gzip for the website, today finishing this article mainly in order to tidy up their knowledge in order to later forget to review. In addition, the CDN provided by the ChinaCache company also has gzip compression enabled.



Install configuration XCache cache method and XCache download under IIS server


Using this accelerator can greatly reduce CPU consumption (but will result in more memory footprint) and shorten the time of Web page execution. The concrete principle does not introduce, the net has many

WIN2003+IIS6 install XCache cache for PHP
Extract the XCache and place the Php_xcache.dll in the php.ini designated Extension_dir (this example is "D:\php\ext").
Start configuration below, open php.ini
Add (remember to add, do not replace the original zend_extension_ts parameters)
Zend_extension_ts = "($extension _dir) \php_xcache.dll"
When configured, replace ($extension _dir) with an absolute path ext (such as: D:\php\ext\php_xcache.dll). Need to be put in front of the Zend.
Add the following items to the end of php.ini, you can copy the following configuration directly ...

 
[Xcache.admin] 
Xcache.admin.enable_auth = off 
xcache.admin.user = "UserName"//Can be modified 
xcache.admin.pass = "PassWord"//Can be modified 
[XCache] 
xcache.shm_scheme = "Mmap" 
xcache.size = 32M//Can be modified by itself 
Xcache.count = 2//Can be modified 
by itself Xcache.slots = 8K 
xcache.ttl = 0 
xcache.gc_interval = 0 
xcache.var_size = 2M 
Xcache.var_count = 2
  xcache.var_slots = 8K 
xcache.var_ttl = 0 
xcache.var_maxttl = 0 
xcache.var_gc_interval = 
Xcache.test = off 
xcache.readonly_protection = off 
Xcache.mmap_path = "XCache" 
xcache.coredump_ Directory = "" 
xcache.cacher = on 
Xcache.stat = off 
Xcache.optimizer = off 
[Xcache.coverager] 
Xcache.coverager = off 
xcache.coveragedump_directory = "" 


The values that need to be modified are already marked in blue, as described below:

 
Xcache.admin.enable_auth XCache Background need to verify (this background in the XCache just downloaded the admin directory, you can freely handle, if not required to set to OFF) 
Xcache.admin.user XCache Background login username 
xcache.admin.pass xcache login password 
xcache.size xcache memory Cache size, the general site recommended set to 64MB, if it is the IDC server,  Can be set 
to 256MB Xcache.count set to the number of CPUs (double accounting 2, such as mine is two dual-core Xeon 3.0, set to 4) 
xcache.var_size 
Xcache.var_count Keep up with two. 
Xcache.mmap_path shared memory identity name, try to use XCache to avoid conflicts with other software 
Xcache.optimizer Optimizer, if not installed Zend can be opened, above we have installed Zend, So set to OFF 



This configuration is complete, restart IIS ...


It is to be noted that

Once you have used XCache all your PHP code changes must be restarted for IIS to take effect.


XCache Download Address:
Http://www.jb51.net/softs/41097.html

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.