views:

84

answers:

2

Hi,

I have an ASP.NET web application and I'm thinking about the following: before sending any HTML or CSS content to users, I wish to 'compress' them, then cache the result and send that to the clients.

I know it is possible to compress these by removing whitespaces, comments and stuff like that, but I'm not really familiar with more advanced solutions for this.

  • Apart from this, what compression methods are there and what are the advantages of each of them?
  • Does some browsers or the HTTP protocol itself support any kind of compression?

EDIT: I'm interested in doing this to dynamically-generated HTML, too.

+6  A: 

gzip is most commonly used for "advanced" compression (i.e., not just removing whitespace). It is supported by all the major browsers: http://www.gzip.org/. It uses the DEFLATE algorithm. If you only want to minify your files, try:

Or try YUI Compressor or any of the other popular ones.

SimpleCoder
So basically you're saying that browsers can decompress gzipped content that is sent to them, right?
Venemo
Yes, you should have no problem with modern browsers and gzip.
SimpleCoder
Very interesting, I somehow missed this possibility so far. Thank you for clarifying it to me! :)
Venemo
Sure, no problem
SimpleCoder
A: 

You can look into any of the minify methods offered by google, yahoo, microsoft for your javascript and css. They all do a good job. Check out this article for tests on all three.

Additionally, you can have IIS gzip compress all your content and even cache it (look at the http headers tab for caching).

Have a look at this article for some other ways to speed up your web app also.

klabranche