Ronnie
Ronnie

Reputation: 5043

What is the best way to gzip and cache static images in Asp.net mvc

I'm trying to find the best way to speed up the delivery of the static images that compose the design of an mvc site. The images are not gzipped, nor cached in the server or on the client (with content expire). Options are:

  1. Find why images are not cached and gzipped direcly from IIS6
  2. Write a specialized http handler
  3. Register a special route for static images and write a bynary actionresult method

What could be the best solution in terms of performance?

Upvotes: 4

Views: 2332

Answers (3)

Simon_Weaver
Simon_Weaver

Reputation: 145930

Surely the gain from gzipping most images is negligable since they're already compressed ?

Naybe you have some really badly compressed PNG files or something?

You might want to check out yahoo's performance advice site which includes some useful tips on optimizing images including links to utilities such as pngcrush.

its much better to use an image optimizing utility ONCE than to rely on IIS to compress them (possibly inefficiently) on the fly.

Upvotes: 2

Paul Mrozowski
Paul Mrozowski

Reputation: 6734

There's a nice library up on the MSDN Code Gallery that does this. It's called FastMVC.

Upvotes: 1

Darren Kopp
Darren Kopp

Reputation: 77627

Best solution is to let IIS do it.

IIS6 Compression - most likely you need to specify file types to be compressed like .jpg, .png, .gif types, etc.

Caching will come from making sure that the correct headers are being sent to the client from code, and i believe there is a setting you can set in IIS that enables it for static content, but i'm not sure on that one.

Upvotes: 3

Related Questions