Freigeben über


ASP.NET 4.0 / AJAX Web Client Performance Improvements (Updated 1/14/10)

Lots of fantastic improvements are coming to ASP.NET 4 with regards to client web performance.  You can be sure that checks for these will be added to future neXpert versions!

Permanent Redirection (ASP.NET 4)

Using Response.Redirect will cause a HTTP 302 to be returned to the client thus creating an extra HTTP request every time.  If the URL has been permanently redirected, you will be able to use the RedirectPermanent.  With this, the first request will result in an extra HTTP 301 however all future requests will automatically go to the new URL. *

RedirectPermanent("/newpath/foroldcontent.aspx");

Smart Script Loader (ASP.NET AJAX)

The client-script loader provides the following web performance enhancements to JavaScript loading

  • Automatically loads all resources that are required by a script.
  • Makes sure that each script is loaded only once.
  • Improves performance by loading scripts in parallel and by combining scripts.
  • Supports loading scripts only when they are needed (“lazy loading”).
  • Supports loading third-party scripts like jQuery and your own scripts.
  • Works with the Microsoft AJAX CDN

Microsoft AJAX Content Delivery Network (ASP.NET AJAX)

The Microsoft AJAX CDN allows you to reference the AJAX framework from a CDN instead of on your local site.  This means that if users are from China but your site is in Seattle, your users will download the AJAX scripts from a server close to them instead of from Seattle.  Reducing latency between the client and server goes a long way to improving web performance.

For more information check out: https://www.asp.net/ajaxLibrary/cdn.ashx

New View State Modes (ASP.NET 4)

ASP.NET view state can add an unnecessary amount of data to your web pages.  The worst part about it is that view state is sent in both  the request and responses to decrease web performance “coming and going”.  Before ASP.NET 4, view state was enabled by default for a page and all controls.  With this new feature, you are able to turn view state off at the page level and turn it on for individual ContentPlaceHolders or the control itself.

<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs"
Inherits="WebApplication1._Default"
ViewStateMode="Disabled" %>

To learn more about these features and others, check out: https://www.asp.net/LEARN/whitepapers/aspnet4/default.aspx

NOTE: These features are present in ASP.NET 4 Beta 2 and are not guaranteed to be in the RTM.

*UPDATE: Internet Explorer will not cache the 301 result and
end-users will always experience the redirect. Firefox and Chrome will cache
the result and automatically take users to the new page when the old URL is
used. This is verified on IE 8, Firefox 3.5.7 and Chrome
3.0.195.38

Comments

  • Anonymous
    February 17, 2010
    Is Microsoft AJAX CDN really available in China now? Because it wasn't at the beginning. I'm not sure if it's blocked or simply because international CDN service provider can't get into China market because of the Chinese policies.