i want outputcache attribute produce header cache-control set public. how do that?
maybe code attribute help
using system; using system.web; using system.web.mvc; public class cachefilterattribute : actionfilterattribute { /// <summary> /// gets or sets cache duration in seconds. default 10 seconds. /// </summary> /// <value>the cache duration in seconds.</value> public int duration { get; set; } public cachefilterattribute() { duration = 30; } public override void onactionexecuted(actionexecutedcontext filtercontext) { if (duration <= 0) return; httpcachepolicybase cache = filtercontext.httpcontext.response.cache; timespan cacheduration = timespan.fromseconds(duration); cache.setcacheability(httpcacheability.public); cache.setexpires(datetime.now.add(cacheduration)); cache.setmaxage(cacheduration); cache.appendcacheextension("must-revalidate, proxy-revalidate"); } }
and use [cachefilter] instead of outputcache
Comments
Post a Comment