1

I have a page with css, javascript, axd, resource files.

My aim is to compress everything so that the response size is reduced and consequently the response time is improved for the end user.

Go to google.com, view source and you can see how google has compressed their contents nicely. that's what I want.

I can't rely on IIS to do any compression so they'd need to be done in the app.

Is there any HttpModule, code, tool to compress all the mentioned elements/files, remove white spaces, etc?

How can this be done?

Update: I'm already using JSBuilder for compressing javascripts into 1 file, also I'm using GZIP for Content-Encoding which has reduced the response size between 50-60%.

The Light
  • 26,341
  • 62
  • 176
  • 258
  • 3
    I assume that the IIS constraint was imposed on you from the outside... You're doing it the hard way; you know that, right? – Robert Harvey Sep 26 '11 at 17:42
  • 1
    IIS Dynamic Compression seems the way to go here, http://weblogs.asp.net/owscott/archive/2009/02/22/iis-7-compression-good-bad-how-much.aspx? – Shan Plourde Sep 26 '11 at 17:55
  • Why do you say "I can't rely on IIS..."? Why not? Please explain. – saille Sep 26 '11 at 19:51
  • I do not have access to IIS on Production. the question was about how to configure it in the app. – The Light Sep 26 '11 at 20:18
  • Then you're in a catch 22. IIS by default serves all static requests directly from the file system without passing them through the ASP.NET runtime. So all of your CSS and JavaScript can't be compressed unless you map everything to the ASP.NET processing pipeline. This might help you to get started: http://stackoverflow.com/questions/552317/how-to-implement-gzip-compression-in-asp-net – Shan Plourde Sep 26 '11 at 20:34
  • updated the question. not sure how to compress css files; also although content encoding is gzip but I can't see any compressed html when I view source; the contents are as before but of course FireBug shows reduction in response size as mentioned. Go to google.com, view source and you can see how google has compressed their contents nicely. – The Light Sep 27 '11 at 07:06
  • 1
    When you use a web browser's View Source option, the browser has always already decompressed gzip compressed HTML by that time. You will never see binary data under normal conditions when you View Source on a standard HTML web page. Also Google's source is not an example of compression, but minification. YUI compressor is an tool that can minify CSS: http://developer.yahoo.com/yui/compressor/ – Shan Plourde Sep 27 '11 at 10:52

1 Answers1

0

I can't rely on IIS to do any compression so they'd need to be done in the app.

IIS would be the ideal place to do it. Do not do it in the app. Happy medium: build script.

Josh Stodola
  • 81,538
  • 47
  • 180
  • 227