WCF 4.5 - Output cache not working RRS feed

  • Question

  • I tried to cache SOAP method response (GET) for 5 minutes. It seems it's not caching and still hitting database on every single call. See my code below. Is there anything specific I am missing below? Is there anything I need to do in the client? 

    <caching> <outputCache enableOutputCache="true"/> <outputCacheSettings> <outputCacheProfiles> <add name="CacheProfile1" varyByParam="none" duration="300"/> </outputCacheProfiles> </outputCacheSettings> </caching>

            string MethodName(string name);
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, Namespace = Constants.Namespace, Name = Constants.Name)]  
        public class MyService : IMyService 

    Thank you,


    Monday, January 6, 2014 8:01 PM

All replies

  • Hi,

    The OutputCache won't work if transferMode is streaming, even if you implement your own OutputCacheProvider. The reason behind this is that: in a streamed response scenario, you're telling WCF not to buffer your response in memory, and try to read it from wherever it is and send it down to transport level. OutputCache depends on the object being fully in-memory before it's returned, so that WCF can keep the reference to it and put that on cache. So please try to check it first.

    Then please try to refer to the following article about the OutPutCache:

    #Integrating ASP.NET Output Caching with WCF WebHttp Services:
    http://blogs.msdn.com/b/endpoint/archive/2010/01/28/integrating-asp-net-output-caching-with-wcf-webhttp-services.aspx .

    #Caching Support for WCF Web HTTP Services:
    http://msdn.microsoft.com/en-us/library/ee230443.aspx .

    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 7, 2014 5:06 AM
  • Hi Amy,

    Thanks for your reply. I am not using 'Streamed' rather using below which is also default I believe.

    I tried again but no luck. Any more ideas? Thanks!


    Tuesday, January 7, 2014 9:53 PM
  • Has there been any resolution on this?

    I'm currently also experiencing the same issue. (and I've been through the links above)

    Tuesday, February 25, 2014 11:52 AM