Search code examples
wcfoutputcachewcf-restwebhttpbinding

Can WCF REST (WebHttpBinding) honor PROGRAMMATIC outputcache policies?


I know all about the AspNetCacheProfileAttribute. But is there any way to hook into the cache programmatically? I've tried using Response.Cache in global.asax which seems to set the correct client-side headers but the response is never cached on the server.


Solution

  • I don't think you can do it unless you build your own solution. I just checked implementation of AspNetCahceProfileAttribute which only add internal CachingParameterInspector to the operation dispatcher. This has two problems:

    • Parameter inspector is assigned when the service host starts = during first request and until that it cannot be changed
    • Parameter inspector is initialized in its cosntructor by reading cache configuration from the web.config file based on the profile name passed to AspNetCacheProfileAttribute

    There is no API available to modify already assigned and configured parameter inspector