none
Caching in WCF data services?

    Question

  • I'd like to use WCF data services in a proof of concept application. I need to know if I used an Entity Framework EDM surfaced through WCF Data Services, would each Data Services query result in a separate call to the database (through the context.) If so, is there a way to cache the data so that most requests get served from memory, and only expired data results in database calls.
    Wednesday, April 14, 2010 7:44 PM

Answers

  • Hi rblitz,

    As for the caching, do you mean the caching at client-side? If so, so far WCF service or DataService doesn't provide built-in cache support. If your WCF service is of REST style and the client is using webbrowser to access, it is possible to utilize the client caching of webbrowser for a certain resource at a given url. If you need to consume the WCF service through .NET client proxy class, you might consider building a wrapper class which perform the cache itself(such as using the Cache application block in enterprise library).

    In .NET 4.0, WCF provides server-side cache feature for REST service:

    #Windows Communication Foundation 4.0 - New REST Features
    http://www.dotnetcurry.com/ShowArticle.aspx?ID=399



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, April 16, 2010 8:31 AM

All replies

  • Hi rblitz,

    As for the caching, do you mean the caching at client-side? If so, so far WCF service or DataService doesn't provide built-in cache support. If your WCF service is of REST style and the client is using webbrowser to access, it is possible to utilize the client caching of webbrowser for a certain resource at a given url. If you need to consume the WCF service through .NET client proxy class, you might consider building a wrapper class which perform the cache itself(such as using the Cache application block in enterprise library).

    In .NET 4.0, WCF provides server-side cache feature for REST service:

    #Windows Communication Foundation 4.0 - New REST Features
    http://www.dotnetcurry.com/ShowArticle.aspx?ID=399



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, April 16, 2010 8:31 AM
  • "So far WCF service or DataService doesn't provide built-in cache support."...

    That really sucks!

    It's already 1 year later after .NET 4.0 has been released and still no caching support?

    I don't even understand how M$ comes with new big features that lack most basic and obvious things!

    Hey Microsoft, wake up... 2010 not 2100!

    Wednesday, November 10, 2010 11:09 PM
  • It seems that you dont understand how browser level caching works.  WCF or any REST based interface can set the the exipriation timeout in the standard header.  When set the requests are cached on the client side and managed by the browser. 


    Haroon
    Wednesday, December 08, 2010 6:23 AM
  • Actually, WCF Data Service is built on top of ASP.net, which means you can utilize its output cache to do what you described there:

     

    http://blogs.msdn.com/b/peter_qian/archive/2010/11/17/using-asp-net-output-caching-with-wcf-data-services.aspx


    Peter Q. http://blogs.msdn.com/peter_qian
    Monday, December 13, 2010 6:33 PM