none
Cache WCF Service response RRS feed

  • Question

  •  have an confusion about aspnet outputcache implementaion in wcf service. I have seen over the internet that aspnet outputcaching is supported by WCF Webttp Service. Does it mean REST API ? If So, then how can we achieve the same thing with normal wcf service (.svc).

    I tried it but not working.

    I created a wcf service and applied all required configuration for outputcaching in web.config as below.

    </outputCache>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="outputtest" duration="100000" location="Server" varyByParam="*"  />
        </outputCacheProfiles>
      </outputCacheSettings>

    In Service I created a method that returns current datetime.

    When I test this service using WCF test client and invoke the method it does not return the same time. Every time it gives different time.

    Please help me.

    Thursday, August 7, 2014 8:23 AM

Answers

  • Hi,
    NET Framework 4/ 4.5 enables us to use the declarative caching mechanism already available in ASP.NET in our WCF Web HTTP services. This allows us to cache responses from our WCF Web HTTP service operations. When a user sends an HTTP GET to your service that is configured for caching, ASP.NET sends back the cached response and the service method is not called. When the cache expires, the next time a user sends an HTTP GET, your service method is called and the response is once again cached. So as you said the aspnet outputcaching is only supported by WCF Rest Service. Then it seems that we can not do it in the WCF SOAP Service.

    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.

    Friday, August 8, 2014 7:29 AM
    Moderator