Asp.net website performance optimization

Source: Internet
Author: User
Tags website performance microsoft website

As the backend optimization space becomes smaller and smaller, more and more websites are paying more attention to the optimization of front-end performance, that is, browser and http optimization. Here we will write two simplest and most effective asp.net website optimization techniques.

Measure the test taker's knowledge about common website performance optimization techniques.

First, we need to learn some theories and basic knowledge about optimizing website performance and experience. Yahoo has already helped us to summarize them. For more information, see several articles in the reference link. I have already translated them into Chinese. Some of the skills mentioned here are highly operable. We recommend that you carefully study and practice each website developer. If you do not know the optimization skills mentioned here, you will not be able to improve the front-end performance of your website.

Diagnose website performance

To optimize the front-end performance of a website, first check which bottlenecks affect the front-end performance? The most common tools are Google's Page Sped and Yahoo's YSlow, both of which are used in Firefox and based on FireBug, fireBug is a required plug-in for front-end developers. These two tools can help you diagnose the performance bottleneck of your page, such as how much network traffic is consumed to open your site homepage and how many HTTP requests are made, whether each page component can be cached, how long each execution process of page loading takes, whether there is blocking during loading, and how the page component is loaded concurrently, whether the image can be lossless compressed, whether the script and style are properly placed, whether unnecessary spaces are deleted, and whether gzip is compressed. With this information, you can optimize the website performance in a targeted manner. First, you can optimize the areas that affect the performance most.

These two tools are easy to use. For more information, see the two articles in the reference link.

Optimization practices

Based on my study and practice on website optimization, I have summarized some experiences: Generally, website performance consumption is concentrated on Online downloads, including HTML, images, and scripts of the page, download styles and other components, especially when the network speed is relatively low, it takes most of the time for the entire web page to be downloaded, local rendering and presentation are usually very fast, unless there are very complex effects or scripts, and the speed of server execution depends on the logic of the specific server, which is more complex to optimize, often the site itself needs to access other backend servers, databases, and so on.

To solve this problem, we can start with two points. First, we can compress the page components. Generally, the images used for the web are in the compression format, so the compression space is not large, and the server CPU is occupied, however, the compression ratio of scripts, styles, and HTML texts is very large with GZIP compression, and most browsers now support GZIP compression. On the other hand, it adds the Http Expire header to the script, style, and image, and the expiration header. The website only needs to download these webpage components when it opens for the first time, you do not need to initiate an HTTP request and load it locally. Of course, the script and style server may change in the future, we need to use URL rewriting to automatically rename scripts and style references to refresh the browser cache after scripts and page updates.

Fortunately, to achieve these two points, IIS7 is very simple. First of all, compression, enable "dynamic content compression" and "static content compression" in IIS Performance Tools in "enable or disable windows functions" in win7, 1.

In the IIS manager, select the website to be compressed and double-click the compression button to add the dynamic and static compression hooks, by default, the mimetype is compressed by text/* and application/x-javascript, which is generally enough, but IIS7 is the default. the js file uses the mimetype of application/x-javascript. By default, the application/x-javascript is dynamically compressed, the difference between dynamic compression and static compression is that it will not be cached by the cache mechanism of IIS. Every access will read files or route requests to the subsequent modules. change mimetype of js to application/javascript, 2

Then perform dynamic compression on application/x-javascript and perform static compression on application/javascript. You need to configure C: \ Windows \ System32 \ inetsrv \ config \ applicationHost. config, as shown in figure 3.

 

Compressing page components has reduced the network traffic and improved the performance. However, some scripts and styles are rarely changed, every time you access a webpage, re-download will consume a lot of network traffic, which requires you to configure the expiration time of the static file.

The IIS7 manager has an HTTP Response Header function. The scripts, styles, and images of a website are stored in the scripts, styles, and images directories, we can set the expiration time for the files in these directories to 100 days. You can directly perform operations in the IIS7 manager. For details, see the reference link, after the configuration is successful, a web is generated in the three subdirectories respectively. config file, and set cacheControlMode = UseMaxAge, cacheControlMaxAge = 100.00: 00: 00. After this setting, the optimization effect will be good. After opening the webpage for the first time, opening the webpage again will be much faster than before, however, one problem is that if your style or script is modified, it will not take effect if the client does not refresh the page. To solve this problem, use URL Rewrite to add a timestamp to the style and Script Reference Path. After the script is changed, the timestamp is changed and the Referenced File name is changed, the browser will download the new style, and the new style is actually the previous name after url rewrite, for example,/scripts/base.2010011502.js is actually/scripts/base. js. For detailed operations, see references.

However, iis6.0 uses the URLRewrite component. In IIS7, there is a free rewrite module, which can be downloaded and installed on the Microsoft website, its Configuration Rules are not the same as those of URLRewrite. The most important difference is that regular expression group matching is not referenced by $1, $2, but in the format of {R: 1, in addition, the target url configuration does not require regular escape characters, such as "." Is ".", It does not need to be "\.", If you do not pay attention to this, please wait for 404. For details about the use and precautions of the rewrite module under IIS7.5, refer to the reference link below. The configuration here is as follows:
Copy codeThe Code is as follows:
{{{
<Rewrite>
<Rules>
<Rule name = "static_file_auto_version">
<Match url = "^ (scripts | styles | images )/(.*?) \. [0-9] + \. (css | js | gif | png | jpg) "/>
<Action type = "Rewrite" url = "{R: 1}/{R: 2}. {R: 3}"/>
</Rule>
</Rules>
</Rewrite>
}}}

Section

After these two optimizations, the website performance has been improved a lot, next, follow the optimization principles provided by Yahoo! and the page speed prompt to see which optimizations can be relatively simple and effective. (Source: frog pond)

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.