tags:

views:

1205

answers:

2

Currently IIS sends an expires http header of yesterday minus 1 hour on ASP.NET pages. How do I change this to 60 seconds in the further instead?

+2  A: 

Go to IIS administration -> -> Properties -> HTTP Headers tab -> click Enable Content Expiration, and set it to whatever you want.

AviD
I enabled content expiration and set expires after to 10 days, but still get the same result (yesterday minus one hour). I also checked the time on the server and it is the current time and date.
Frederik Vig
Just occurred to me, is this for HTTPS pages? ASP.NET by default forces immediate expiration for "secured" pages, the thinking being if it requires transport security it shouldnt be cached either.
AviD
Unfortunately no, it's normal HTTP pages.
Frederik Vig
Then you may need to do a little debugging. Where is the expiration coming from - header or meta? Added by IIS, ASP.NET, or ASPX page code? What does it look like, might there be two conflicting instructions?
AviD
Found it, IIS diden't work and neither did META tags. But setting it programmaticly in my code-behind did the trick :).
Frederik Vig
Content Expiration headers apply to static content. It is assumed that dynamic content will set whatever headers are required.
AnthonyWJones
+3  A: 

You can also add a content-expires page directive to your ASP.NET page (for different expire schedules):

@Outputcache

Or you can set the header inside your code (perhaps a base page class):

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));

A good article on caching can be found on MSDN:

http://support.microsoft.com/?scid=kb%3Ben-us%3B323290&x=11&y=6

Johannes Hädrich