views:

135

answers:

3

Hi

I am looking at my performance in yslow and even though I gzipped my css and js scripts it says I should gzip my html page.

Compression reduces response times by reducing the size of the HTTP response. Gzip is the most popular and effective compression method currently available and generally reduces the response size by about 70%. Approximately 90% of today's Internet traffic travels through browsers that claim to support gzip.

I am wondering should I do this? And if so how do you do that when using asp.net mvc with C#?

+4  A: 

Yes, you should be doing this, it'll dramatically reduce your payload delivered to the client (faster page load, yay!). This is done in IIS (if you have the option, it's not the only option, e.g. blowery, etc).

Disclaimer: There is some cost to doing this in terms of CPU to actually do the compression. However, it's always been worth it in my experience. If you have an extremely high traffic site, you may need to weigh the costs though (though if you pay for bandwidth, I'd bet it's still a clear win).

Nick Craver
See my comment to you in the above post. So basically if I could have a soultion that gzips it dynamically for my asp.net mvc 2.0 if IIS can't be configured but if it can be configured then use IIS 7.0(which seems to be the better route from your post)
chobo2
@chobo2 - Your host should have the compression modules installed. You just need the appropriate `web.config` entries and you're ready to go, there's a full write-up here: http://www.iis.net/ConfigReference/system.webServer/httpCompression
Nick Craver
Hi could you give me an example of what would go in the web.config that tutorial you gave does not mention anything about a web.config. I guess I should be using "Dynamic Compression" as well as all my pages are views(.aspx) pages?
chobo2
@chobo2 - Which host are you with? They *should* have already enabled this, that last link I added was the schema for this. If you can say which host though, they probably have a support page for exactly this.
Nick Craver
I am with http://www.reliablesite.net/v3/index.asp but I thought yous aid I have to do something in the web.config to make it work.
chobo2
@chobo2 - You do it in the `web.config` *if* the host allows it (via `ApplicationHost.config`, which determines which options are available for you. Which hosting package are you on? Since they offer dedicated hosting, I'm not sure how much access you have.
Nick Craver
I am on the shared hosting plan http://reliablesite.net/v3/shared.asp
chobo2
A: 

Static resources are gzipped by default. You only need access to IIS to configure compression of dynamic resources.

liammclennan
I don't believe this is correct...by default neither module is even installed, you'll need to enable both, at least the last time I built a Windows 2k8 R2 server.
Nick Craver
"IIS7 has Static Compression enabled by default""HTTP compression is usually available on the default installation of IIS 7. However, only static compression is installed by default.""The compression scheme in IIS7 is enabled by default"see http://programmerramblings.blogspot.com/2008/01/iis7-http-compression.html, http://www.iis.net/ConfigReference/system.webServer/httpCompression, http://stackoverflow.com/questions/786638/how-can-i-get-gzip-compression-in-iis7-working
liammclennan
A: 

This is probably a premature optimization.

"Premature Optimization is the root of all evil." -Knuth

Writing new features and making your site better is probably a more efficient use of your time.

jfar
Gzipping your html output is about as low hanging fruit as you are going to find when optimizing a website's performance. There is nothing "premature" about it.
Jace Rhea
I think you need a balance of alot of things. If you go "I am going to make just features" you might just end up with a super slow site. If you go I will do some super optimization to say 1kb then you probably wasting time where you could have used it to make new features and finally testing can't ignore that one too.
chobo2
Pretty amazed at the downvotes. There are a lot bigger fish to fry and gzipping some html. Are all the database queries tuned and indexed? Images optimized and CDN'ed? Is your app/site growing? Do you have bugs? Are there feature requests? SEO rankings good?
jfar
I think it's a little crazy to call this premature optimization. We aren't talking about refactoring some sort method here. chobo2's flipping a switch to enable gzipping html, something with substantial, tangible, proven benefits. And for essentially zero effort. I guess you could spend a lot of time tuning all your queries first, but why should anyone wait to do this?
joeynelson
@jfar It takes less than a minute to turn on gzip. How can you argue a sizable improvement in download speed (one of the biggest bottlenecks in a web app) is less important than any of the things you listed?
Jace Rhea
@jfar I think this is the exception that proves the rule. HTTP compression is so easy you have absolutely no reason not to do it.
Jaco Pretorius