Ben
Ben

Reputation: 5192

caching remote json (or xml) calls (from webservices)

Any clues on how to do it ?

Upvotes: 2

Views: 482

Answers (2)

Fenton
Fenton

Reputation: 251162

You have two options, you can use either / or both.

1) Cache the call at the web service. You need to ensure that the cache is indexed against the exact parameters used so you don't send back "the wrong answer" to a request.

For example "http://webservice/GetSomething/983" should only cache the result of "GetSomething" where the id parameter is 983. If another request for 983 comes in, you can use your cache, otherwise you'll make a new request.

2) Cache the response at the client. Be careful about doing this with large volumes of data as you'll start consuming too much memory. Essentially, you create a JavaScript cache for the response data - you'll still need to bear in mind the parameters used for the call to ensure you don't use an item in the cache that was called using different parameters.

Upvotes: 3

Notinlist
Notinlist

Reputation: 16640

In what language? Generally: Use the function signature and actual parameters as key and serialize and store the answer with a timestamp. Next time check for it.

Upvotes: 1

Related Questions