Search code examples
c#.netiishttpwebrequestsystem.net.httpwebrequest

How does HttpWebRequest cache responses? And why recycling app pool did not work?


What is the way of HttpWebRequest cache works?

I tried recycling the app pool on IIS in which my web application is hosted but I was still getting cached responses.

So cache entries are not stored in memory? How exactly it works?


Solution

  • Cache is stored on disk.

    HttpWebRequest uses the WinINet caching which is the underlying caching mechanism for Internet explorer. Files are stored in Temporary Internet Files folder which the same location where IE stores temp content. So, if you delete the Temporary Internet files, the cache would be cleared.

    From another answer from StackOverflow

    HttpWebRequest uses System.Net.Cache.RequestCache for caching. This is an abstract class; the actual implementation in the Microsoft CLR is Microsoft.Win32.WinInetCache which, as the name implies, uses the WinInet functions for caching.

    Another good article here