Last post Feb 18, 2021 09:30 PM by mgebhard
Feb 18, 2021 04:48 PM|TimJin|LINK
When we update a value on the database, we want to update it in the cache. Normally the application pool recycles in every 29 hours. What if I manually recycle the application pool for the application? Is it going to affect user experience? Any side effects?
Or other than application pool recycle, is there better way to clear cache?
Thank you in advance!
Feb 18, 2021 05:10 PM|PatriceSc|LINK
Depends how the app is written and configured. It's basically a restart and so you could for example lose session variables etc...
Rather than depending on that you could use a lifetime or
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/detecting-changes-with-sqldependency to refrresh cached data without having to "restart" the application.
Feb 18, 2021 08:58 PM|TimJin|LINK
I think yours is a good solution for frequently changing data. In my case, we only change the value couple times a year. If I add dependency to all the sql command everytime, it might cause performance issue. After reading the article you mentioned above,
it seems to be checking database all the time and it is good for systems with frequently changing data.
What I want is to safely clear an application cache manually or automatically. I want the safest way and one that is best practice. Thank you for your answer.
Feb 18, 2021 09:30 PM|mgebhard|LINK
In my case, we only change the value couple times a year.
How is this a problem? Your cache lasts over a year?
What if I manually recycle the application pool for the application? Is it going to affect user experience?
Depends on how your application is designed. You are the only one that know how a restart affects your application. Application memory is cleared so anything that depends on memory will be lost. Any information that cannot be reloaded can be a problem.
Since you already recycle every 29 hours then the likely hood cache is stale is very very low. There are 5780 hours in a year. Also, every cache API has an expiration. Make the expiration a fraction of the recycle period; 29/2 or 29/4 or 29/8.
Lastly, whatever process updates the database can send an HTTP request to the app to the reload cache.