As the title says, how can i clear Outputcache on client side? I have several ajax calls that needs to be cleared after user does some specific actions.
I tried:
Response.RemoveOutputCacheItem(Url.Action("Action", "Controller"));
But it didn’t work.
I even tried to expire it mannually (even though this would be a bad approach):
Response.Expires = 0;
Response.ExpiresAbsolute = DateTime.Now.AddMinutes(-1);
Response.AddHeader("pragma", "no-cache");
Response.AddHeader("cache-control", "private");
Response.CacheControl = "no-cache";
That didn’t worked out too.
Just to be clear, i’m using OutputcacheLocation = Client. If i set it to Server the examples above work flawlessly.
If what you need is the axax call to return different data each time despite caching, when called with the same arguments, the only reliable way is to add another variable in the query string, which is always different, e.g. the time down to the millisecond.
Here’s how I do it (parameter no_cache):