Search code examples
asp.netcachingiis

How to clear the server cache in iis


I've got a asp.net web site on windows with rather over the top server side caching of files that never change. Unsurprisingly the files have changed. How do I reset the server side cache? I've see lots of how to do it in code but I don't want to add a new page that will clear the cache unless I have too. An IISreset or a box reset will clear the cache but that's rather drastic. Will an application pool recycle? The app pools are set to terminate after idle time out, that'll probably happen overnight will that clear the cache?

code is:

using WebApi.OutputCache.V2;

namespace Foo.Web.API.Controllers
{
    public class BarController :  ApiController
    {
        [HttpGet]
        [CacheOutput ServerTimeSpan = 31536000)]
        public HttpResponseMessage Get(string organisationId, string file)
        {

Solution

  • Both clear the cache. Recycling an App Pool is just less drastic, as it continues to process already received requests and cycles after that. This can be done under load - never had issues with it.