views:

24

answers:

1

Programmatically how do i add expire header? I am not using IIS, i'd like to do this in ASP.NET itself or maybe how to do it with apache which is what i am using.

+2  A: 

See How to: Set Expiration Values for ASP.NET Page Caching

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);

If you set expirations for a page programmatically, you must set the Cache-Control header for the cached page as well. To do so, call the SetCacheability method and pass it the HttpCacheability enumeration value Public

DaveB