How to decrease the page load time in ASP.NET application?
Asked Answered
P

11

8

How to decrease the page load time in ASP.NET application? What should be the precautions and specially when we are interacting with databases

e.g.

  1. wise use of viewstate
  2. Set in web.config when deploying the app

    etc

Postage answered 30/6, 2010 at 11:24 Comment(1)
possible duplicate of Building ASP.NET application - Best PracticesShudder
S
11

Some of the key "take-aways" from TechEd 2010 North America:

  • Caching is key to performance, consider your caching strategy very carefully.
  • Disable viewstate if possible.
  • Set <compilation debug=”false"> in web.config when deploying the app.
  • Consider CDN's or subdomains for graphics and other static content.
  • Place javascript at the bottom of the page, CSS at the top.
  • Consider CSS sprites for icons and other "small" graphics.

You can watch the sessions online here, they're both highly recommended:

Spade answered 30/6, 2010 at 11:52 Comment(1)
E
3

80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, stylesheets, scripts, Flash, etc.

http://developer.yahoo.com/performance/rules.html

I'm not suggesting ignore the view state and database caching suggestions in the answers already provided. I'm pointing that for what I've found to be simplier alterations is to go for turning on GZip Compression in IIS, setting expiry headers on static elements to reduce server requests, optimize images using a tool such as smush.it

Run a report of your site using Zoompf for a very detailed report with estimate impact and easy of implementation ratings.

Elephantine answered 1/7, 2010 at 21:13 Comment(0)
S
3
  1. Never ever Deploy asp.net application under debug configuration on production. Find out here what scottgu has to say about this.

  2. Use Cookie-less domains to serve static resources like images, scripts, styles etc. Each client request is sent along with whole bunch of cookies, you don't need cookies while serving pictures or scripts. So host those resources on a cookie-less domain.

  3. Minify scripts, stylesheets and HTML response from the server. Removing unnecessary line-breaks and white-spaces can improve the time-to-load and bandwidth optimization.

You'll find many tips from here.

Shudder answered 11/8, 2010 at 9:25 Comment(0)
B
2
  • Try to minimize ViewState as much as possible or keep it on the server
  • Use caching of data or portions on your page by using outputcaching of user controls
  • Bundle scripts and css as much as possible

Always measure after you refactored something to see if it makes a difference.

Also please take a look here for more information.

Grz, Kris.

Birgitbirgitta answered 30/6, 2010 at 11:31 Comment(0)
K
1

You could always trigger an async database action and have the page updated asynchronously - AJAX update panel comes to mind.

There is also Page Output Caching, useful if the page is largely static. It can also be done based on parameters, so you could potentially cache the page created for a given database search.

You can also take the over-the-top approach and reduce the "wordiness" of a page. I did this once for fun on a products page by shrinking the names of elements etc, managed to cut over 50% of page size, but it makes the markup entirely unreadable lol

Along this same route, apply reduction tools to css/javascript files - merge them too if you compress as compression becomes more efficient over fewer larger files.

Katalin answered 30/6, 2010 at 11:44 Comment(0)
C
1

The most important thing before doing any work on optimizing, is indicating what needs to be optimized. Thousends of tips to optimize can be posted here, so it's better to find what your performance problem is, and ask a more specific question for help to optimize what you need. You can optimize 3 parts of a web application:

Serverside performance: Indicate the largest bottleneck (a profiler is an easy option to do that). Optimize the bottleneck. Optimizing smaller problems, or optimizing without measuring the amount of time can be a waste of time when the large one is still there.

Client side performance: Take the advise from tools like yslow, or google page speed.

Bandwidth: Send the smallest amount of data to the user as possible in the least amount of requests as possible.

Charie answered 30/6, 2010 at 11:54 Comment(0)
A
0

There is an interesting article on MSDN with 10 tips to optimize ASP.Net apps. Its at

http://msdn.microsoft.com/en-us/magazine/cc163854.aspx

Amice answered 30/6, 2010 at 11:33 Comment(0)
M
0
  • Cache as much db reads as possible
  • reduce/disable viewstate
  • do less (if possible)
Monoclinous answered 30/6, 2010 at 11:42 Comment(0)
T
0
  • Use MS Visual Studio 2010 which helps you in optimizing your .NET code for better performance.
  • CSS sprites are very useful when you have a lot of images in background.
  • Compress the contents of JavaScript files using gZip compresser and CSS file by removing white spaces and comments.
  • Avoid HTML comments as they are visible to client side by "View Source" option in browser, which will also reduce the file size.
  • Put most of the unnecessary JavaScript at the bottom of the page. For better performance dynamically load the JavaScript references after loading contents on your page.
Thaumatology answered 26/7, 2010 at 3:56 Comment(0)
C
0

Always use request to load concept in application. Try to avoid unwanted database hit on the page load.if you have large amount of data on page load then you can go with Ajax request call.

Curtis answered 17/4, 2012 at 12:17 Comment(0)
A
0

This below information used to decrease the page load time

  1. Remove unwanted line space while hosting site.
  2. Merge all inline css file into one common .css file.
  3. Merger all inline Java scripts into one common .js file and add reference to this file whenever you require.
  4. use compress Javascript and CSS files.
  5. Try using less images with less size in your web page.
Applicator answered 13/10, 2017 at 12:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.