If you have been following any of my articles you will know that I am always looking for ways to improve performance. Nothing is more frustrating than to go to a site and it seems like an eternity to load. This little helpful hint not only will increase performance but also minimize bandwidth requirements.
If you are like me than you have a multitude of images that rarely change on a site. Many of them are used in layouts, buttons, navigation, etc. If you do have a lot then why not tell the browser to use the images that have already been downloaded before. Once again in IIS 7 you can add the following to your web.config. It’s in the system.webServer section.
[code language=”xml”]
<staticContent>
<clientCache httpExpires="Sat, 21 Sep 2013 00:00:00 GMT" cacheControlMode="UseExpires" />
</staticContent>
[/code]
This will cause static content to be tagged with an expiration date of September 21. 2013. Once this hits then the next time a user comes to the site it will deliver the image again.
Although this is an acceptable way, this means that you will have to go and change the expiration date once September 21, 2013 comes along. I actually prefer to use this syntax.
[code language=”xml”]
<staticContent>
<clientCache cacheControlMaxAge ="5.00:00:00" cacheControlMode="UseMaxAge" />
</staticContent>
[/code]
This sets the static content to expire 5 days from today. So in theory, if a user comes to your site every 5 days then they would download the static content again.
It is important to realize that the definition of static content is anything that is not served through the ASP.NET engine. This means that things like images, style sheets, javascript files, etc will not be downloaded before the expiration date.
Looking for quality web hosting? Look no further than Arvixe Web Hosting!