четверг, 23 июня 2011 г.

Server side no-cache

To prevent unexpected client caching (e.q. in IE) we implemented NoCacheAttribute in REST services.

We use for services ASP.NET MVC technology. So, we created custom ActionFilterAttribute:

public class NoCacheAttribute : ActionFilterAttribute

{

public override void OnActionExecuted(ActionExecutedContext filterContext)

{

filterContext.RequestContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);

}

}

To use no-cache ability we need just mark our controllers with this attribute. In our case we marked base plugin controller and resource controller (that provides TP entities).

Комментариев нет:

Отправить комментарий