views:

480

answers:

7

Is there any way to compress an html page or html output of asp.net page to make them load faster. I heard that Google is using that technology someway.

Thanks in advance.

+2  A: 

You can use HTTP Compression in IIS 6/7. Refer to http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d52ff289-94d3-4085-bc4e-24eb4f312e0e.mspx?mfr=true or you could look at caching your ASPX page, refer to http://www.4guysfromrolla.com/articles/121306-1.aspx

Kane
A: 

Do a google search for the term "gzip"

WebDevHobo
+3  A: 

It's certainly possible to turn on http compression to reduce the size of the data transmitted over the network and all modern browsers will know how to unzip the response. It only improves the load time due to less data being transferred though. If that's not where the bottleneck is, you may not see the improvement you're hoping for. You may also want to look at tools like YSlow or Page Speed if you're looking for other ways of improving the performance of a web page.

Bernard Chen
+2  A: 

Yes, delivering the page as Content-Encoding: gzip will probably deliver the page itself to the browser more quickly. But if the real problem is that the page appears to the user to load slowly, you need to remember that the process of displaying the page has several parts, of which you're looking at only one. After loading the HTML for the page itself, the browser still has to parse it, start executing any scripts in the page, and load any further data (such as images) that the page requires. This last part taking a lot of time is often what makes a page appear to display slowly.

Curt Sampson
Does gzip encoding work with IE ? Sometime back it wasnt.
Sathya
Yes, IE supported gzip encoding from 4.0 on up, though there were some problems that needed to be patched with certain versions. More generally, you should be looking at the Accept-Encoding http header (though that won't correctly handle broken implementations).
Bernard Chen
+1  A: 

If you are using iis 6 here is a really easy way to enable compression.

http://lunarmedia.com/blogs/lunarmedia_blog/archive/2007/11/05/iis6-http-compression-quick-and-easy-four-steps.aspx

geoff
+1  A: 

Another, non IIS specific approach is to measure what parts of your page are taking the most time to load. A good and free tool is yslow from Yahoo!
You can also try to optimize your image files with tools like pngcrush or the online utility smush-it
If you are using a lot of CSS you can minimize it with CSSTidy.

weichsel
+1  A: 

I know your using asp.net, but for anyone who comes across this and is using apache, the best (fastest, least cpu intensive) method of compression is mod_deflate, .

This is what I use in my .htaccess:

# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

Source: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

And for evidence that it is faster: http://www.google.co.uk/search?q=deflate+vs+gzip

Sam
Thanks,maybe I need it someday :)
Braveyard