Asp. NET website performance improvement several methods

Source: Internet
Author: User
Tags server memory website performance

1. HTTP compression

HTTP compression is typically used to compress page content returned from the server. It compresses HTTP requests and responses, and this can be a huge performance boost. My project was developed based on window Server 2003 and can be referenced in this article .



2. Make ViewState invalid

ViewState allows the page state to remain on the client side, which is not distinguished from cookies or server memory. View state holds data in a hidden field. To be sure, this is a very powerful feature, but its drawbacks make the page size and memory in the server grow.

So, we want to avoid using ViewState, especially the DataGrid and other controls, viewstate load all the tabular data in the state. By removing it, you can make the size of the page smaller.



3. Changing the Web. config file

A. Using page caching:

This will save your page for a certain period of time, and the page can be loaded more quickly. Keep in mind, however, that if your page data is updated frequently, it is not appropriate to use page caching.

<caching> <outputCacheSettings> <outputCacheProfiles> <add name= "Cached" duration= "600" Varybyparam= "None" enabled= "true"/> </outputCacheProfiles> </outputCacheSettings> </caching>

B. Removing unnecessary httpmodule from the Web. config:

<add name= "Scriptmodule" type= "System.Web.Handlers.ScriptModule, System.Web.Extensions, version=3.5.0.0, Culture =neutral, publickeytoken=31bf3856ad364e35 "/> <remove name=" windowsauthentication "/> <remove name=" Passportauthentication "/> <remove name=" anonymousidentification "/> <remove name=" UrlAuthorization "/ > <remove name= "fileauthorization"/>

C. Turn off tracing:

<trace enabled= "false" pageoutput= "false"/>

D. When user membership is used, the profiles save is automatically invalidated:

<profile enabled= "true" automaticsaveenabled= "false"/>

E. Set the debug state to False:

<compilation debug= "false" >



4. Increase the cache Dependency:

The three-way cache dependencies can be used:

1. Caching dependencies in the traditional cache entry;

2. Caching dependencies on the document;

3. Caching dependecies on SQL;

You should choose the best strategy to adapt to your application, here is a file on the cache dependency example can be referenced below.



5. Optimize CSS style sheets:

It is very important to clean up the CSS stylesheet, removing useless code can improve the efficiency of page loading, in the project, you can use the tool to compress the size of the style sheet, you can use the CSS Online compression tool to compress the size of the CSS code.



6. Optimize JavaScript code:

You can use the JS Online compression tool to optimize your JavaScript code.



7. js and CSS file location:

Put the CSS file as far as possible on the head of the page, the JS file as far as possible at the bottom of the page.


8. If possible, replace the Server.Transfer () with the Response.Redirect ()

This will load the page more quickly because it is just in the post form without having to refresh the entire page.


9. In terms of authentication, use client script:

You can avoid postback callbacks.

Asp. NET website performance improvement several methods

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.