Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set the expiry date or a maximum age in the HTTP headers for static resources in IIS

Tags:

caching

iis

I am using IIS 6 and IIS 7 as a web server.

After running Google page speed online , it remarks that I should be: Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.

And it lists a lot of plain images , my javascript files and the style sheets.

How can I set this expiry date for these static files ? I thought this was done automatically by the browser ?

like image 457
Edelcom Avatar asked Apr 06 '11 03:04

Edelcom


People also ask

How do I enable caching in IIS?

Configure Output Caching Through the IIS ManagerFrom the Start menu, click Administrative Tools, and then click Internet Information Services (IIS) Manager. In the tree view on the left side, find your application. Select the Output Caching menu item. In the right column, click Add in the Action menu.

What is clientCache?

The <clientCache> element of the <staticContent> element specifies cache-related HTTP headers that IIS 7 and later sends to Web clients, which control how Web clients and proxy servers will cache the content that IIS 7 and later returns.


1 Answers

Leverage browser caching:

Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.

http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching

To set an expiry date or a maximum age in the HTTP headers for static resources

Open IIS manager-> Click your site-> Click the HTTP Response Headers in the home page-> Click the Set Common Headers on the Actions panel -> Check Expire Web Content -> Set After 7 days (as suggested for in the page speed analysis "Specify an expiration at least one week in the future for the following resources"

http://technet.microsoft.com/en-us/library/cc770661%28WS.10%29.aspx

like image 137
Rami Sarieddine Avatar answered Sep 23 '22 07:09

Rami Sarieddine