If you use YSlow plugin as an assistant to help you improve your website performance, you probably saw that by default you get an F grade on “Add Expires headers” section.
What exactly are Expires Headers?
Below is an explanation from Yahoo Developer website:
Browsers (and proxies) use a cache to reduce the number and size of HTTP requests, making web pages load faster. A web server uses the Expires header in the HTTP response to tell the client how long a component can be cached.
How to Add Expires Headers?
There are quite few methods to do this. You can set the expires 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:
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.