ASP.NET Google SPDY Tweaks

B01I0067

Google recently introduced the SPDY initiative where they are working toward making the web twice as fast.

If you have a public facing web site that is commercial in nature, speed has always been a factor that will drive sales, sign-ups, etc.  But we very rarely pay any attention to this, even though the solutions are relatively simple.

Now that Google is on a quest for a faster web, they have a number of ways they can achieve this.  One of those is by telling us that they will give bonus points to sites that are fast.  And that’s exactly what they’ve done.

While page title, relevant content, and links to a page will still be the  primary components of search engine ranking, it won’t hurt to make your pages load as fast as they can.  So what can we do as programmers to make our sites faster?

Use the Page Cache directive

This is probably the easiest “fix” to site speed that you can implement.  If your page is essentially a static page, or at least “static” for several hours at a time, use the cache directive to prevent it from re-computing every time it is requested.

Cache your User Controls

You are using User Controls on your site, right?  Did you know you could put the output cache directive in the User Control too?  So maybe all your pages really are dynamic at some place.  But I bet a significant number of your user controls are pretty static.  Cache them.

Cache your data

Did you know that you don’t need to retrieve your data from your data store every time you render the page?  The ObjectDataSource has several properties that control this: EnableCaching, CacheDuration, CacheExpirationPolicy, and CacheKeyDependency.  Check it out.

Consider Using the Substitution Control

If you only have one small part of your page that is changing, you could cache the entire page and use the substitution control to fill in the section that needs to change every time the page is loaded.

Replace your old-fashioned JavaScript

If you are using a lot of JavaScript on your page, you should consider moving to a library like jQuery.  This will cause your pages to load faster because the code you will be writing will take significantly less space and the library that supports it is small enough to load quickly.  It’s worth considering.

Reduce the number of files any one page needs.

While having a lot of little CSS files makes the project easier to manage, the down side is that loading 4 different CSS files on one page will make the page load more slowly.  I generally try to have one site-wide CSS file and, if necessary, one page-specific CSS file.  No more.

Don’t go crazy with the graphics

This goes along with the number of files point.  More graphics means more trips to the server.  More trips mean a slower load time.  It is amazing what can be done with CSS and JavaScript these days.  Look into using a solution that doesn’t require graphics prior to throwing a lot of graphics in your CSS to make the site look good.

Turn on static file compression.

Go into IIS and make sure that it is set to compress all of your static files.

Be intelligent about ViewState

I know a lot of people are saying “just turn the darn thing off.”  But that’s not the solution.  It may in fact make more sense to use ViewState than to make another trip to the database.  There  is also the problem of caching stuff you have no reason to cache.  Did you know that 99% of the time a TextBox and a Label control’s cache will have absolutely no impact on the functionality of your code?  Yet they will use up space.  Know why you are using ViewState if you are using it at all and I bet your page size will shrink quite a bit.

I’m sure there are other things you could do, but if you just start with this list you’ll be well on your way to a well optimized site.

 

Other post in Seach Engine Optimization

Like this Article? Subscribe to get every article sent to your email.

Related Post

About Dave Bush

Dave Bush is a .NET programmer and Certified ScrumMaster who is passionate about managing risk as it relates to developing software. When he is not writing or speaking about topics related to Application Lifecycle Risk Management (ALRM), he is an example to his peers as he develops web sites in the ASP.NET environment using industry best practices.

Awards & Certs