locked
REST Service Caching with WebChannelFactory RRS feed

  • Question

  • I'm consuming an internal REST Service using WebChannelFactory. The main motivation for using REST is transparent outputcaching, and using the WebChannelFactory rather than HttpClient allows it to be consumed in a strongly typed manner (additionally supporting intellisense and rename refactorings) without add/update service references.

    However, for some reason the caching support with WebChannelFactory is flaky. Can't seem to figure out how to get good caching behavior...

    Any ideas? Does WCF ChannelFactory not respect these settings? Is there something else that might cause this sort of behavior that I should look for?

    • Edited by JRS52 Friday, June 29, 2012 8:12 PM
    Friday, June 29, 2012 5:51 PM

Answers

  • Hello, a true RESTful service is resource oriented rather than operation oriented. So WebChannelFactory may not work. But if the service happes to use WCF as well, and you have access to the service contract, you can use WebChannelFactory. In general, it is recommended to use WebClient or HttpWebRequest to work with REST services. They should respect to the Cache-Control header.

    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email.

    • Marked as answer by Yi-Lun Luo Friday, July 6, 2012 8:32 AM
    Monday, July 2, 2012 6:58 AM

All replies

  • I guess what I'm looking for is the WebChannelFactory equivelent of WebClient.CachePolicy, if there is one...
    • Edited by JRS52 Friday, June 29, 2012 8:11 PM
    Friday, June 29, 2012 8:07 PM
  • Hello, a true RESTful service is resource oriented rather than operation oriented. So WebChannelFactory may not work. But if the service happes to use WCF as well, and you have access to the service contract, you can use WebChannelFactory. In general, it is recommended to use WebClient or HttpWebRequest to work with REST services. They should respect to the Cache-Control header.

    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email.

    • Marked as answer by Yi-Lun Luo Friday, July 6, 2012 8:32 AM
    Monday, July 2, 2012 6:58 AM