How to optimize your IIS server step by step

  

Windows Server's own Internet Information Server (IIS) is a common tool for setting up a web server. It is a simple and troublesome thing, novices can Using IIS to set up a decent Web site, but configuring and optimizing the performance of IIS to make the site access performance optimal is not a simple matter. Here I will introduce how to optimize your IIS server step by step. .

Server-side environment, we take Windows Server 2003 IIS6.0 as an example, the client environment is Mozilla Firefox 3.0, and Yahoo's YSlow extension is installed.

YSlow is a Firebug-based plugin released by the Yahoo developer team. It is used to analyze webpages and score according to the rules of some high-performance websites. It is very helpful for webpage performance optimization, telling you which parts affect your webpage speed and telling you how to use certain rules. optimize. Our optimization strategy for IIS is based on YSlow.

Open the target website using Firefox with YSlow installed, then click the YSlow icon and click Performance.

Where Performance Grade is YSlow's rating on your website, A (100 points) is the highest, F is the lowest, and the following is how to modify it. Below I will use IIS 6.0 as an example to introduce how to optimize website performance. .

1, reduce the number of HTTP requests

This is mainly to modify the website code, reduce the number of external images, CSS, JS and other files, manually merge multiple CSS /JavaScript files. There is no need to set up IIS.

2, use CDN

For small websites, this is free. Of course, rich people can try, can technically solve the problem of slow response time for users to visit the website.

3, enable content expiration

Enable content expiration for static files to improve access performance. First of all, the directory of the website should be divided reasonably. The pictures, CSS and JavaScript are all placed in separate directories. Then select the directory in IIS, click the attribute - HTTP header, enable the content to expire, you can choose to go after 30 days, so the user browser will compare The current date and expiration date, in order to decide whether to display the cached page or to request the updated page from the server. Since the picture, CSS, and JS usually change less, they are basically read from the local cache, thereby speeding up the display.

4, enable Gzip compression

HTTP compression is a method of transferring compressed text content between a web server and a browser. HTTP compression compresses HTML, JavaScript, or CSS files using common compression algorithms such as Gzip. The biggest benefit of compression is to reduce the amount of data transmitted by the network, thereby increasing the access speed of the client browser.

To use, right click on "Website" -> "Properties" and select "Services". In the "HTTP Compression" box, select "Compress Static Files". The "Temporary Directory" is recommended to set the directory of another disk separately.

After that, in the IIS Manager, right click on "Web Service Extension" -> "Add a new Web Service Extension", enter "HTTPCompression" in "Extension", add "Required File" For C:\\WINDOWS\\system32\\inetsrv\\gzip.dll, where the Windows system directory may vary depending on your installation, check "Set extension status to Allow".

Finally, use a text editor to open C:\\Windows\\System32\\inetsrv\\MetaBase.xml, add the static file suffix name to be compressed in HcFileExtensions, the default is HTML and TXT files, it is recommended to add js , css, etc., do not add images or ZIP files that have been compressed.

5, put the style file in the head

This is the basic HTML code style, put all the CSS files in the head of the HTML page.

6. Put the script file at the end

This is also the basic HTML code style, putting all the JavaScript files at the end of the HTML page.

7, avoid CSS expressions

This is very simple, because most people never use CSS expressions.

8, using external JavaScript and CSS

All JavaScript and CSS are referenced in the form of external files, mainly to allow these files to be cached by the browser. See the introduction of the third point.

9, reduce DNS query

Domain name DNS query will bring additional access costs, reduce the number of host domain names in the page, the host domain name of a page remains within 2-4 This will not slow down the page loading speed.

10, compressed JavaScript files

Compressed script files, delete unnecessary characters, can improve the loading time, there are many compression tools for JavaScript files, I have a GUI interface JS compression Tools for download.

11, avoid redirects

Web page redirection will bring additional operating overhead, so avoid the page redirect jump operation.

12, delete duplicate scripts

A page containing the same JavaScript file twice will affect the performance of the load, so you need to delete the duplicate script file.

13. Configuring ETag

This is a confusing question. In theory, deleting the ETag of the server will improve the performance of the HTTP request, but configuring IIS 6.0 according to the modification method provided by Microsoft officially has no practical effect. Finally, I used a remetag to implement the function of deleting ETag in ISAPI mode.

Summary

After the front-end refactoring of these websites and the configuration modification of the WEB server, our page structure has become more standardized, and most of the refactored pages will get a good YSlow score. Overall, the performance has improved a lot. For the end user, it is also obvious that the speed of visiting the website is much faster, and the browsing experience of the website has been improved.

Copyright © Windows knowledge All Rights Reserved