How to do WCF REST Caching?

2019-04-12 01:38发布

问题:

I have a WCF REST service which needs to return both Static and some filtered data based on what parameters were passed in by the clients(which are fat windows clients)

Since the data store which feeds this service doesnt change too often, I wanted to cache this data on the service(Server side caching), The data store is an Azure Table, I know WCF REST Starter kit has Web Cache for caching but it needs a web.config entry to do a fixed duration caching(ex: 30mins). I wanted to do this in code whenever my azure table entry changes. How can I accomplish this?

Also Since I have some processing/filtering to do on my service based on the parameters passed in, seems like I would have to create 2 methods, one private method with caching to get the data and the other one to process/filter and send back the results. Correct?

回答1:

Check out some of the various blog post on the topic:

  • REST in WCF – Part X – Supporting Caching and Conditional GET
  • Adding caching to WCF RESTful services using the REST Starter Kit
  • Caching support for WCF REST services (.NET 4 beta)

Also check out the official MSDN WCF REST developer center for more information.



标签: rest caching wcf