I have encountered a weird problem: as far as I know, cache can be cleared by recycling the application pool.
However, in a recent project, cache is not cleared in that way. Instead we had to reset IIS to clear the cache.
What are the differences between these actions, and what might be the cause of the differences I've experienced?
What is application pool recycling in IIS? Recycling means that the worker process that handles requests for that application pool is terminated and a new one is started. This is generally done to avoid unstable states that can lead to application crashes, hangs, or memory leaks.
When you do an IISReset the IIS cache will be cleared and then will start to be rebuilt after it starts back up as client requests come in. If you update a file then the older cached file will become stale and IIS will serve the updated file and update the cache with the new file.
Does IISRESET recycle the application pools? The correct answer is no. Instead, IISRESET causes the shutdown of all active IIS worker processes, kills them if they do not stop in time.
IISRESET is a dinosaur from the before-times, specifically before IIS 6.0 shipped in Windows Server 2003. With IIS 5.0 and earlier versions of IIS, the web server was a monolith. An IIS reset tool was needed for restarting the web server process to resolve performance issues that may have developed in the application.
When you recycle the AppPool, there is some overlap time. Your unhealthy worker process is marked for recycling, but continues to handle requests that it has already received. (It will not handle new requests). The unhealthy worker will be terminated once all its existing requests are handled.
With IIS reset, all workers are terminated and the cache in memory is cleared. New workers will be created once new requests come in.
So I think that for both an AppPool recycle and an IIS reset will clear the cache. As for as I know, that cache is stored in the Application domain. Once the unhealthy worker process terminates, all cache items should be destroyed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With