Search code examples
c#asp.net.netc#-4.0outputcache

Persist page outputcache


Is there an option to make page outputcache persist even after IIS restart or web.config modification?

Right now when I upload files the site recompiles and the outputcache resets and get cached upon the next page request.


Solution

  • You can implement your own outputcache provider by implementing the OutputCacheProvider:

    public abstract class OutputCacheProvider : ProviderBase
     {
       public abstract object Get(string key);
       public abstract object Add(string key, object entry, DateTime utcExpiry);
       public abstract void Set(string key, object entry, DateTime utcExpiry);
       public abstract void Remove(string key);
     }
    

    For further reading and how to implement you can read: creating-a-custom-output-cache-provider

    More resources to read: scottgu extensible-output-caching-with-asp-net-4-vs-2010-and-net-4-0-series