a-man
a-man

Reputation: 707

Force update cache when using OutputCache

I am using ASP.NET Web Forms app with OutputCache set to xxx seconds. How can I invalidate cache when it is required to do? Specifically, I want to check if data in database is modified and if true, then force cache update. Is it possible and how to achieve that? So far I have added:

<%@ OutputCache Duration="24000" VaryByParam="myId" location="Server"%>

Now the problem is that Page_init is not fired with OutputCache and I dont know how to force cache update.

Any ideas are welcome!

Thanks!

Upvotes: 1

Views: 612

Answers (1)

Hamed Bohlouli
Hamed Bohlouli

Reputation: 36

Try this

var urlToRemove = Url.Action("AjaxHtmlOutputMethod", "Controller");
HttpResponse.RemoveOutputCacheItem(urlToRemove);

Upvotes: 2

Related Questions