There are quite few methods to do this. You can set the Expire Headers directly from IIS, you can write a custom HttpHandler or if you don’t want custom functionality you can set them from Web.config file.
Below you have an example of how you can set the expiration date from Web.config:
<system.webServer> <staticContent> <clientCache cacheControlMaxAge="30.00:00:00" cacheControlMode="UseMaxAge"/> </staticContent> </system.webServer>
The first number from cacheControlMaxAge field is the number of days. That is also the default value that I keep on my websites.
Note: In order to get an A grade from YSlow plugin, you have to set the value to more than 7 days.