views:

106

answers:

6

I'm developing a newsletter in asp.net that will be send to a large quantity of users, so each kilobyte that I can reduce will help a lot in the use of bandwidth consumption, what I do until know is write the aspx excluding some spaces between tags, and before render, i've renamed some controls ids to "-" to save more space. So now, the file has 50kb. I need a file with 25 Kb.

Can anyone teach me any other way do save more space ?

ps.: I Use 3 divs with some data, and 2 repeaters, one inside other, to generate a table with some data for me.

EDIT: I've disabled viewstate, and remove unnecessary divs, I'll try to verify if gzip is enabled in IIS.

thanks in advance

+2  A: 

You can disable the viewstate and optimize image files if you are using any.

TheGeekYouNeed
+1 for viewstate. That is the number one thing that increases the size of your rendered page.
AaronS
thank you, i've already disabled viewstate and in fact it saved a huge space. I'm not using any image.
Rbacarin
ViewState is not Cache.ViewState: http://msdn.microsoft.com/en-us/library/ms972976.aspxCache: http://msdn.microsoft.com/en-us/library/aa478965.aspx
Tim Schmelter
+1  A: 

I recommend going over this article if your using ASP.Net Web Forms - explains how to correctly utilize ViewState:

http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx

Alexander
in fact i don't really need viewstate in a newsletter, so i've disabled it. thank you man
Rbacarin
+4  A: 

Make sure HTTP compression is enabled. It will help to reduce the amount of HTML, but enabling HTTP compression will give more than the marginal improvements you're likely to see.

There are different ways to enable compression, depending on your version of IIS. For instance, in IIS 6.0, you can manually edit metabase.xml or run:

cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true 

You can check HTTP headers to verify that compression is enabled using something like https://addons.mozilla.org/en-US/firefox/addon/3829/ Live HTTP Headers for Firefox. Check your headers for "Content-Encoding: gzip".

bleh
Good catch -- I didn't read the question that way, but your way makes total sense. I read it as he was emailing out a newsletter, not a link to a newsletter. Then I was trying to figure out how compression on the server would have anything to do with the generated html that gets put into the body of an email. :)
Matt Dawdy
@Matt, for sure. Likely he/she'd be better off generating a static page too..
bleh
Absolutely. That's one method many sites completely ignore, and therefore use up a LOT of CPU and database time generating the same views over, and over, and over...
Matt Dawdy
Each User will see diferent newsletter depending of the configurations that have made, SO I can't generate only one page.
Rbacarin
+1  A: 

You might want to look into IIS Compression(it uses gzip IIRC). That should knock the file size down.

Also minify the javascript/css(I've done that and seen up to 40% reduction on js/css file sizes), here's a link to a book/website that talks about other things you can do: http://developer.yahoo.com/performance/rules.html, the book's title is "High Performance Web Sites", the ISBN: 978-0-596-52930-7

Chris L
+1  A: 

It may not work out to much savings, but you can also reduce markup by seriously considering whether to use DIVs for styling purposes when styling the contents directly would achieve the same result.

For instance,


<div class="sidebar">
  <ul>
    <li>Lorem</li>
  </ul>
</div>

In most cases you can get the same result from styling the UL directly:


  <ul class="sidebar">
    <li>Lorem</li>
  </ul>

But in your case, the repeaters are probably the main source of the bloat. Make sure you're using a custom template for them with clean HTML, and not relying on the out of the box rendering, which can be quite messy.

Like someone else posted, turn off viewstate for any controls you don't need it on - that's a TON of junk alone.

Superstringcheese
thank you, i liked this advice about remove some unnecessary divs...
Rbacarin
+3  A: 

Don't use an aspx page if you want full control. Make a Generic Handler, and then you can have full control over every byte generated.

Instead of using Repeaters, just loop through a dataset and output tables or spans or something. Although, I have to say, repeaters are very easy to control the exact output of, too.

Look at your generated html and see if you can identify any obvious culprits.

Matt Dawdy