IIS7 asp.net site to optimize site performance skills

Source: Internet
Author: User
Tags format config end header http request iis net microsoft website
First of all, we have to learn some optimization of the site performance and experience of the theory and the basic knowledge, Yahoo has helped us to sum up, see the reference links in several articles, a kind-hearted person has been translated into Chinese.

Web server performance optimization has a lot of data introduced, multiple host load balancing, query results of multi-level caching, database index optimization are common optimization methods. As the back-end optimization space is getting smaller, more and more sites pay more attention to the front-end performance optimization, is the browser, HTTP optimization, here to write two of the simplest and most effective ASP.net website optimization skills.

Learn about common Web site performance optimization techniques

First of all, we have to learn some optimization of the site performance and experience of the theory and the basic knowledge, Yahoo has helped us to sum up, see the reference links in several articles, a kind-hearted person has been translated into Chinese. This is mentioned in some of the skills are very strong, it is recommended that every Web site developers carefully learn and practice, you can say that do not understand this inside said optimization skills, improve the front-end performance of the site is impossible to talk about.

Diagnosing Web site performance

To optimize the front-end performance of the site, first of all, to see the most impact on front-end performance bottlenecks are? The most commonly used tool is Google's page sped and Yahoo's YSlow, both are used under Firefox, and is based on Firebug, Firebug is a prerequisite for front-end developers a plugin. These two tools can help you diagnose the performance bottlenecks of your page, for example, open your site A total consumption of network traffic, how many times the HTTP request, each page component can be cached, page load each execution process each occupy a lot of time, loading whether there is blocking situation, Page components in parallel loading, whether the picture can be lossless compression, the script and style placement is reasonable, whether to remove unnecessary whitespace, whether the gzip compression and so on. Know this information, you can be targeted to optimize the performance of the site, first the most impact on the performance of the place to optimize off.

These two tools are also very simple to use, see the reference link in two articles.

To optimize the practice

According to my study and practice of website optimization, summed up some experience: The general Web site performance consumption is concentrated in the network download, including the page itself HTML and pictures, scripts, styles and other components of the download, especially in the slow speed, download these things to spend the entire page to render most of the time, After downloading these things, local rendering and display will be quickly, unless there is a very complex effect or script, and the speed of implementation of the server to see the logic of specific servers to optimize the complexity of the high, often the site itself to access the backend of other servers, databases and so on.

To solve this, there are two points to start with, the first is to compress the page components, the Web use of the picture is generally the compression format, so the compressed space is not too large, but also occupy the server CPU, but the script, style, HTML text content with gzip compression is very large, And most browsers now support gzip compression. On the other hand is the script, style, the image plus the HTTP expire header, plus this expiration, the site only need to download the first time the Web page components, and then open even HTTP requests do not have to launch, directly loaded locally, of course, script and style server may later change, We need to use URL rewriting to automatically rename scripts and style references to refresh the browser cache after script and page updates.

It is gratifying to do this two points, in the IIS7 is very simple, first of all, compression, in the Win7 using the "Turn on or off Windows features" in the IIS Performance tool in the "Dynamic content compression" and "Static content compression," as shown in Figure 1.

Then in IIS Manager, select the site to compress, double-click the compression button to add dynamic compression and static compression on the line, the default will be mimetype for text/* and application/x-javascript compression, generally this is enough, However, IIS7 defaults to the. js file using the Application/x-javascript mimetype, and the default to Application/x-javascript is dynamic compression, The difference between dynamic compression and static compression is that it will not be cached by the caching mechanism of IIS, and every visit will read the file or routing request to the following module, so we will change the. js MimeType to Application/javascript, as shown in Figure 2

Then the application/x-javascript is dynamically compressed, and the application/javascript is compressed statically, and the configuration C:\Windows\System32\inetsrv\config\ ApplicationHost.config, figure 3 below

The page component has been compressed has been reduced a lot of network traffic, improve the performance, but some scripts and styles rarely change in general, every visit to the page to be downloaded or will consume a lot of network traffic, which requires the configuration of the expiration time of static files.

IIS7 Manager has an HTTP response header function, the general Web site scripts, styles and pictures are placed in the Scripts,styles,images directory, we directly for these directories to set the file expiration time of 100 days is OK, In the IIS7 manager can directly operate, see the reference link, do not repeat, the set will be successful in these 3 subdirectories to generate a Web.config file, and set the Cachecontrolmode=usemaxage, Cachecontrolmaxage=100.00:00:00 this set after the optimization effect is very good, the first time you open the page, open the page again than before, many times faster, but there is a problem is if your style or script changes, if the client does not refresh the page, it will not take effect. Solve this problem using URL rewrite to put the style, the script's reference path adds a timestamp, and if the script changes, the timestamp changes, the filename of the reference is changed, the browser downloads the new style, and the new style actually passes through the URL rewrite or the previous name, such as/ Scripts/base.201001111502.js is actually/scripts/base.js, see the reference article for concrete operation.

But the article says is iis6.0 uses Urlrewrite component, in IIS7 has a free rewrite module, installs on the Microsoft website to install on the line, its configuration rule and the urlrewrite are not very same, the most important difference is to the regular group match not to use $, A $ reference, instead of using the {r:1} format reference, and the target URL configuration does not require a regular escape character, such as ". "Yes". ", do not need to be" \. "If you don't pay attention to this, wait for 404, the specific IIS7.5 under the rewrite module use and attention to see the following reference link, I have the following configuration

{{{
<rewrite>
<rules>
<rule name= "Static_file_auto_version" >
<match url= "^ (scriptsstylesimages)/(. *?) \. [0-9]+\. (cssjsgifpngjpg) "/>
<action type= "Rewrite" url= "{r:1}/{r:2}". {R:3} "/>
</rule>
</rules>
</rewrite>
}}}

Section

After these two optimizations, the site performance has been improved a lot, and then follow the principles provided by Yahoo and page speed to see what is more simple and effective to optimize the



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.