However, it is not easy to configure and optimize the IIS performance so that the website access performance reaches the optimal state. Here I will introduce how to optimize your IIS server step by step.
For the server environment, take iis6.0 of Windows Server 2003 as an example. The client environment is Mozilla Firefox 3.0 and the yslow extension of Yahoo is installed.
Yslow is a firebug-based plug-in released by the Yahoo developer team. It is used to analyze Web pages and rate the pages according to the rules of some high-performance websites. It is helpful for web page performance optimization and tells you that some of them affect the speed of your web pages, it also shows you how to optimize based on certain rules. Our optimization policy for IIS is based on yslow.
Use Firefox with yslow installed to open the target website, click the yslow icon, and click performance, as shown in.
Among them, performance grade is yslow's rating for your website, A (100 points) is the highest, F is the lowest, and how to modify it is listed later, the following uses IIS 6.0 as an example to describe how to optimize website performance.
1. Reduce the number of HTTP requests
This is mainly to modify the websiteCodeTo reduce the number of external images, CSS, JS, and other files, and manually Merge multiple CSS/JavaScript files. You do not need to set IIS.
2. Use CDN
This is free for small websites. Of course, rich people can try to solve the problem of slow response speed when users access the website.
3. Enable content expiration
Enabling content expiration for static files improves access performance. First, the website directory should be reasonably divided. images, CSS, and JavaScript should be placed in a separate directory, and then select a directory in IIS, click Properties-HTTP header, and enable content expiration, you can select 30 days later. In this way, your browser compares the current date with the end date to determine whether to display the cache page or the page requested to be updated from the server, because images, CSS, and JS are usually less changed, they are basically read from the local cache to speed up display.
4. Enable gzip Compression
HTTP compression is used to transfer compressed text content between web servers and browsers. HTTP compression adopts common CompressionAlgorithmSuch as gzip to compress HTML, JavaScript, or CSS files. The biggest advantage of compression is that it reduces the amount of data transmitted over the network and increases the access speed of the client browser.
To use this function, right-click "website"> "properties" and select "service ". Select "compressed static files" in the "HTTP compression" box. We recommend that you set a directory for another disk separately.
Then, in IIS manager, right-click "Web Service extension"-> "Add a new Web Service extension", and enter "httpcompression" in "extension ", add "required file" to c: \ windows \ system32 \ inetsrv \ gzip. DLL, the Windows System directory may vary depending on your installation, select "set extension status to allow ".
Finally, Open c: \ windows \ system32 \ inetsrv \ metabase in the text editor. XML: add the extension name of the static file to be compressed in hcfileextensions. The default value is HTML and TXT files. We recommend that you add JavaScript and CSS files instead of compressed files such as images or ZIP files.
5. Place the style file in the header
This is the basic HTML code style. All CSS files are placed in the header of the HTML page.
6. Put the script file at the end
This is also the basic HTML code style. All JavaScript files are placed at the end of the HTML page.
7. Avoid CSS expressions
This is simple, because most people never use CSS expressions.
8. Use external JavaScript and CSS
Reference all JavaScript and CSS files in the form of external files to make these files accessible to the browser. For more information, see section 3.
9. Reduce DNS queries
The DNS query of a domain name will incur additional access overhead, reducing the number of host domain names of files on the page. The host domain name of a page is kept within 2-4, so that the page loading speed will not be reduced.
10. Compress JavaScript files
Compressing script files and deleting unnecessary characters can improve the loading time. Currently, there are many Javascript file compression tools. Here I have a javascript compression tool on the GUI for download.
11. Avoid redirection
Webpage redirection brings additional operation overhead. Therefore, you must avoid page redirection and jump operations.
12. Delete duplicate scripts
When a page contains the same Javascript file twice, the loading performance is affected. Therefore, you must delete the duplicate script file.
13. Configure etag
This is a confusing question. Theoretically, deleting the server's etag will improve the performance of HTTP requests. However, configuring IIS 6.0 according to the modification method provided by Microsoft does not work, finally, I used a third-party DLL file to implement the etag deletion function through ISAPI.
After the preceding website frontend reconstruction and web server configuration modification, our page structure becomes more standardized, and most of the reconstructed pages will get a good yslow rating, in general, the performance has improved a lot. For end users, they will also feel that the website access speed is much faster and the browsing experience of the website has been improved.
Reference books: high-performance website construction guide-published by e-Industry Publishing House