1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Cache Custom WCF Service in SF

Cache Custom WCF Service in SF

8 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    09 Mar 2012
    Link to this post
    Is there a way to cache the results on WCF if the Uri is the same?  I've got a slow widget on my page (calls back to a slow service) and it keeps re-running every new page visited....Is it possible to cache so that WCF doesn't have to keep re-running it?
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    13 Mar 2012
    Link to this post
    Hello Steve,

     Where exactly do you want to cache the items? If you want to do that on the client, here's a blogpost with more info on caching with javascript:
    http://davidwalsh.name/cache-ajax 
    Also, if the service is slow, are you sure that your data-taking code is fully optimized?

    Regards,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    13 Mar 2012
    Link to this post
    Yeah, she's as optimized as she can get...it has to talk to an external service (Google Docs), parse and return the results.

    So I would like the caching to be serverside if WCF can do that at all?

    Like if I load up my browser, and there's an ajax call to the service, that's already happeded in X timeframe with the same parameters...return the cached results instead of re-running the entire method.

    Does such a thing exist?

    Steve
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    16 Mar 2012
    Link to this post
    Hi Steve,

     If you are consuming an external service, then the server of that service is responsible for its data-caching. The only thing you can do is cache the result on the client, as you are not making any calls to your own server.

    Greetings,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    16 Mar 2012
    Link to this post
    Yeah I guess that's kind of what I was getting at :)  So with the WCF\SF Cache...is that what "outputCache" is supposed to do for me?

    "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"

    However even though I configured i, I was always getting the method called
  6. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    21 Mar 2012
    Link to this post
    Hello Steve,

     The definition is correct, but this matters only if you are getting the response from YOUR server. As far as I understand you are making a call directly to the google server to consume their service and you have no control over their own cache.

    Greetings,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    21 Mar 2012
    Link to this post
    Hey Svetoslav,
      Yeah that's what I'm getting at, I'm calling MY .svc files inside of my sitefinity instance.  Internally those are then using the Google API to call back to google...so I know I have no control over their cache :) So why isn't this working here for me in Sitefinity with WCF?

    Steve
  8. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    26 Mar 2012
    Link to this post
    Hello Steve,

     I see what is the case now. The output cache configuration acts only for Sitefinity services, not for custom ones, so this is why it is not working in your case. What you need to do is implement the caching yourself, like you would do in a regular ASP.NET application. Here's a link that can help you:
    http://msdn.microsoft.com/en-us/library/aa478965.aspx 
    Focus on this topic 

    Caching API, Using the Cache Object

    The caching needs to be performed in your wrapper service and it will be used to return the cached result rather than making new calls to the google service. 

    Greetings,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
8 posts, 0 answered