1

I am maintaining an application in which the developer has used data caching in the following manner:

HttpContext.Current.Cache["key"] = myDataSet;

He hasn't specified when this cache gets invalidated. The myDataSet is a result of a SELECT from the database. The database was updated, but the cache is not invalidated. I do not want to change the source code. I simply want to invalidate it. I tried iisreset with no luck.

4 Answers 4

3

If you re-save the web.config, the app pool will recycle more gracefully than an iisreset, with the same result for the cache.

Sign up to request clarification or add additional context in comments.

2 Comments

@Chris: The question title is a bit misleading. The code in the question is just using the ASP.NET cache, not output caching.
Thanks for the clarification Luke, I have updated my answer accordingly
1

The solution is going to be somewhat dirty anyway if you can't change the code (the clean way would be to use SqlCacheDependency).

Can you change the Global.asax.cs (although it's source code as well)? You can access the HttpContext from here and empty the cache in your code.

1 Comment

Well, not really. I don't have access to deploying source on that server. I do have remote access and can do what needs to be done in the IIS (if that would help)
1

iisreset should work. Whenever the ASP.Net application is unloaded from memory it will clear out any server managed Session data. Even just touching the web.config should unload the app.

Comments

0

iisreset did work! I did'nt notice the changes as the IE was caching the datasets. So, the original question is not fully accurate.

Thanks

1 Comment

Yeap- it will always work, though touching the web.config as Keplerf1 mentions is a better technique.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.