Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fast ASPX Pages with CSS Class - External JavaScript - Small Viewstate

Status
Not open for further replies.

Meleagant

Programmer
Aug 31, 2001
166
US
All,

I am in the midst of trying to speed up an Asp Net site. I've read a couple of articles on how to squeeze as much speed out of pages as possible. Of the articles I've read 3 things kept on reoccurring: Control the ViewState, use CSS instead of <asp:Control ForeColor="Red" BackBolor="Blue" etc.. and if you have a lot of inline JavaScript move it to an external file.

I have done all of these and have noticed no real improvement. In fact I've slowed things down quite a bit. On the main user work page, sort of like a Case Management Page:
- Before I started the ViewState was over 150,000 charecters long. Now it is a tenth of that.
- I've moved my javascript to an external file and even ran a "minimizer" against it and now the js file is 47K as opposed to 75K.
- I've moved lost of my asp:GridView row styling to CSS classes.

The average file size sent to the client is now 210K down from 374K, BUT THE PAGE IS BLOODY WELL SLOWER! Why would pumping a smaller file across the network be slower? Does anyone have any idea's/suggestions?

Thanks,
-- Joe --

* Sine scientia ars nihil est
* Respondeat superior
 
you are now pulling more files across the network. this could be 1 reason. port80 offers Http Zip. I have only read about this tool, haven't used it yet. this may be worth looking into.

if you pages continue to run slower return to your previous setup with js and css inline.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
BUT THE PAGE IS BLOODY WELL SLOWER
Have you proved this with actual timings? If not, turn on tracing in both pages and have a look at the results. Also, run both pages through and see what the results are.



------------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
 
Yep, spent a portion of the morning timing via PC Anywhere to one of our satellite offices. When a user enters an account number it takes between 18 - 30 seconds for the page to load completely. In our production system it would take about 10 - 15 seconds, depending upon the amount of data for that account. I did turn Tracing on and I looked at the data stored in the viewstate. Prior to my playing around the _ViewState was over 150,000 characters. Now for the same account it is more like 17,000 characters. Granted that is huge but it is a lot better than it was. I'll try that web site that you mentioned and see what that tells me.

I can understand the initial load taking a little longer. There is one Css sheet and one external javascript file. I ran that through a minimizer and now the file is 47K, down from 75K. I thought once the page is loaded the javascript would be cached and no longer needed to be retransmitted back to the client on any subsequent server requests (i.e. changing tabs, button clicks, etc.)

I just don't understand...theoretically wouldn't an 180K file load faster than the 374K version of the same file? All I did was remove the viewstate from the gridviews and other controls, and went with CSS for the styling instead of skinning them

Thanks for your reply I really appreciate it.
 
When a user enters an account number it takes between 18 - 30 seconds for the page to load completely

It sounds like the primary problem is that you're optimizing the code in the wrong place. There's no way the browser should take 30 seconds to download and render a 180k file. The performance problem is probably somewhere else.

It sounds like the first thing you may want to do is implement paging for your data.

See here:

MCP, MCTS - .NET Framework 2.0 Web Applications
 
The performance problem is probably somewhere else.
I agree. If you look at the results from your tracing, I'd be very surprised if the entire time was just down to downloading each file. Instead, make sure you put Trace.Warn statements at relevant intervals in your code to find out which sections are taking the longest to locate potential problems.


------------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
 
The main "Case Management" page is a multi-tabbed (10 tabs) page. It is actually an Infragistics UltraWeb Tab. Each tab loads on demand and I have confirmed this. They will not execute their server side scripts until the user selects that tab.

To make things more complicated I have 3 entry points depending on the 'TabNo' sent in the query string.
-- Tab 1 is just an overview pages with about 30 pieces of information. I ditched the <asp:Label.../> controls for the static information and replaced those controls with the HTML <Label.../>. I figured I didn't need a server control just to display "Case Date:".
-- The second tab has three gridviews, but each grid control would hold only 5 rows at a maximum. So paging won't help me.
-- The third tab, like the second, had 4 grids. These will only hold about 10 - 15 records at a maximum.
__________________________________________

Now I have used Paging and Caching the <asp:ObjectDataSource.../> to great effect in other pages, pages where my result set can easily reach 3,000 records. I just don't think it would help me much here.

I have timed out how long my Tab_Load routines take for each tab. I dropped a "log start" at the beginning and a "log end" and the end. The Load Routine, including SQL calls, take only around 2 seconds. The rest of the time I'm waiting for the page to load, which is why I thought that if I made the page smaller, it would load quicker.

I'll try putting in the Trace.Warn statements as well as examine the trace data more closely.

Thanks all for taking the time to give me a hand!!

Thanks,
-- Joe --

* Sine scientia ars nihil est
* Respondeat superior
 
You're right about paging not helping, but something's still not right. The smaller page size isn't where you'd want to look.

How is the performance if you don't use the Infragistics control? Is there an authentication problem on the network? Do you have Visual Studio Team System so you can use the code profiling (to let you figure out how long each bit of code takes to run) and web test tools?

MCP, MCTS - .NET Framework 2.0 Web Applications
 
I could try to copy out the HTML and Server Side code for Tab1 and put it into a new document and see what happens.

-- A side note:
We started using a lot in Infragistics tools, (web grids, drop downs, buttons and the like) but we did notice that they seemed to take a long time to render to the page. Especially the web grid. As soon as you put a couple of hundred rows into the Ultra Web Grid it was really really slow. So I switched them out to the asp:Grid view and things are much faster based from the original design. Now I am trying to take that next step to speed up the web site over the improvements I have already made.

I don't think there is a authentication problem, but I'm not sure where/how I would look to know for certain.

I've never played with VS Team Systems. I'm running VS2005 Standard Edition SP1. I'll do a quick Google on VS Team Systems and see how to use it and if I can use it.

I'm reaching the limits of my .Net knowledge and I've asked to boss if I could go to some sort of advanced training and although he said yes I don't have the time. So I read a lot of articles and try various solutions and learn as I go. Thanks for your suggestions and thanks for replying to my questions.

Thanks,
-- Joe --

* Sine scientia ars nihil est
* Respondeat superior
 
One quick thing I forgot to mention --

I did enable tracing on the page. The total time was 2.0161156055457. Does this mean, as far as the server is concerned, that it took my page 2.01 seconds to load? Then why does my stopwatch say 14 seconds for the page to completely load? Here is a snippet from the trace, so my form load event (which includes all of my SQL calls to populate Tab1) took 1.56 seconds? That's pretty quick, then what could be the cause of the slowness of the page?

aspx.page Begin Load 0.733846401611982 0.000016
[form1_Load] Start 0.73877715256684 0.004931
[form1_Load] End 1.55162251661604 0.812845
aspx.page End Load 1.56518410874861 0.013562



* Sine scientia ars nihil est
* Respondeat superior
 
your stop watch is also including the time required to cross the network and render on your browswer. if i'm not mistaken, tracing only applies to actions on the server. so maybe the problem is network latency or client cpu?

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
If you only have VS 2005 standard, it will cost thousands to upgrade to Team System edition (which might be worth it if you want to do things like load-testing your application:
As far as the performance problem, I think the Infragistics controls should indeed have a big target painted on them right now. I'd be curious to see what would happen using alternate controls.

MCP, MCTS - .NET Framework 2.0 Web Applications
 
I already was looking at the Team System Dev Center and noticed that it wasn't a free add-on or something similar...oh well.

I can tell you from experience with both Windows based Infragistics controls and Web based ones, that the Win based controls are great, no complaints. The web based ones have been really really slow. I already mentioned that we (I) replaced all of the UltraGridViews with the asp:GridView as well as drop downs, buttons, etc. They seem to be too "fancy" when I can achieve the same styling with a Microsoft control.

Thanks for all of your help. Right now I am reading "Improving ASP.NET Performance" article from the MSDN ( I got a feeling that most of it will be way over my head...but gotta start somewhere.

When I remove the web tab, I'll post back and let you all know if it helped.

Thanks,
-- Joe --


* Sine scientia ars nihil est
* Respondeat superior
 
Put a Trace.Warn line into the first line of the Page.Init event and another one into the last line of the Page.PreRender event.

Then record the trace and render times for the following actions:
-How long to render the page on LocalHost? (web server)
-How long to render the page on LAN? (client pc on local network)
-How long to render the page on your remote site?


That data should tell you where to look. If you post them all back, I would be interested to take a look.


Senior Software Developer
 
I can't run from my local host for some Oracle reason. I'm a SQL Server guy, and I am working for an Oracle shop.

But on the LAN with the servers 20 feet away from me, I time the page at 5.2 seconds with my stop watch. Here is the trace:
Code:
aspx.page Begin PreInit   
 [Page_PreInit] 0.000290087516164927 0.000290 
aspx.page End PreInit 0.0345398935370365 0.034250 
aspx.page Begin Init 0.0346206369733241 0.000081 
aspx.page End Init 0.707202953294638 0.672582 
aspx.page Begin InitComplete 0.707250819524225 0.000048 
aspx.page End InitComplete 0.7072638446964 0.000013 
aspx.page Begin PreLoad 0.707275552614959 0.000012 
aspx.page End PreLoad 0.707433331328381 0.000158 
aspx.page Begin Load 0.70744924363177 0.000016 
 [form1_Load] Start 0.712328357041893 0.004879 
 [form1_Load] End 1.50403808908003 0.791710 
aspx.page End Load 1.51717251511233 0.013134 
aspx.page Begin LoadComplete 1.51720741631831 0.000035 
aspx.page End LoadComplete 1.58327840365703 0.066071 
aspx.page Begin PreRender 1.5833234669634 0.000045 
 [Page_PreRender] 1.58358286968813 0.000259 
aspx.page End PreRender 1.77888476737542 0.195302 
aspx.page Begin PreRenderComplete 1.77892942768639 0.000045 
aspx.page End PreRenderComplete 1.77894272051968 0.000013 
aspx.page Begin SaveState 1.84346423265466 0.064522 
aspx.page End SaveState 1.84448570569306 0.001021 
aspx.page Begin SaveStateComplete 1.8445034585426 0.000018 
aspx.page End SaveStateComplete 1.84451677844275 0.000013 
aspx.page Begin Render 1.84452872996301 0.000012 
aspx.page End Render 1.98741012901868 0.142881

At our satilite office the same page will take 24.5 seconds. Here's the trace
Code:
aspx.page Begin PreInit   
 [Page_PreInit] 0.000298745902378876 0.000299 
aspx.page End PreInit 0.0485337523683498 0.048235 
aspx.page Begin Init 0.0486341313043217 0.000100 
aspx.page End Init 0.736576487925175 0.687942 
aspx.page Begin InitComplete 0.736624462422183 0.000048 
aspx.page End InitComplete 0.736637887582328 0.000013 
aspx.page Begin PreLoad 0.736649697753451 0.000012 
aspx.page End PreLoad 0.736807392258879 0.000158 
aspx.page Begin Load 0.736823406814833 0.000016 
 [form1_Load] Start 0.74170658927551 0.004883 
 [form1_Load] End 2.61946815734865 1.877762 
aspx.page End Load 2.63275770653514 0.013290 
aspx.page Begin LoadComplete 2.63279225286458 0.000035 
aspx.page End LoadComplete 2.67838302306698 0.045591 
aspx.page Begin PreRender 2.67842356019368 0.000041 
 [Page_PreRender] 2.6785744639259 0.000151 
aspx.page End PreRender 2.89716706865959 0.218593 
aspx.page Begin PreRenderComplete 2.89721251090193 0.000045 
aspx.page End PreRenderComplete 2.89722613154492 0.000014 
aspx.page Begin SaveState 2.96160515172476 0.064379 
aspx.page End SaveState 2.96260790051427 0.001003 
aspx.page Begin SaveStateComplete 2.96262624883462 0.000018 
aspx.page End SaveStateComplete 2.96263893416739 0.000013 
aspx.page Begin Render 2.96265067817509 0.000012 
aspx.page End Render 3.10480521788818 0.142155

Any ideas?


* Sine scientia ars nihil est
* Respondeat superior
 
i come back to network latency. try this:
copy the html souce into an html file.
access the html file from the remote office.
time how long it takes the page to load.

if it's around 20 seconds it rules out the code.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Followed your suggestion, viewed the source of the aspx page and saved as an HTML file to the desktop. Except for a couple of script errors and missing images, the file rendered in about 1.3 seconds. Now the question is how do I get around a slow network?


* Sine scientia ars nihil est
* Respondeat superior
 
Were there script errors because it couldn't find the Infragistics scripts? If so, don't ignore the possibility that the scripts themselves are causing the performance problem.

MCP, MCTS - .NET Framework 2.0 Web Applications
 
I got IE6's Active Content blocker. Once I click on the "Information Bar" and clicked allow I saw my page. Sorry didn't mean to confuse anyone


* Sine scientia ars nihil est
* Respondeat superior
 
bolderbum said:
don't ignore the possibility that the scripts themselves are causing the performance problem.
good point. have you checked on Infragistics' forums for other users have latency issues?

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top