24 May 2012
Set no cache in WCF service
protected static void SetNoCache()
{
OutgoingWebResponseContext response = WebOperationContext.Current.OutgoingResponse;
response.Headers.Add("Cache-Control", "no-store");
response.Headers.Add("Pragma", "no-cache");
}
protected static void SetCache(TimeSpan span)
{
OutgoingWebResponseContext response = WebOperationContext.Current.OutgoingResponse;
response.Headers.Add("Expires", DateTime.Now.Add(span).ToString());
}
protected static void SetCache(int expiration)
{
OutgoingWebResponseContext response = WebOperationContext.Current.OutgoingResponse;
response.Headers.Add("Expires", DateTime.Now.AddMinutes(expiration).ToString());
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment