0

I notice that when I update a feed (set a new value) and then read the feed, the data returned does not always include my last update. It's as if Xively is returning a cached response. Eventually (after 5 minutes or so) a request will result in the new value will be returned.

This is a development-mode device; I can see the new value reflected in the Xively status page for the device immediately following the update. I've also noticed that the requests resulting in out-of-date data do not appear in the Xively Request Log. After 5 minutes or so of sending requests and getting out-of-date responses a request will appear in the Request Log and an up-to-date response will be returned.

I update my feed like this: curl -X PUT -d@feedupdate.json -H X-ApiKey:my_key http://api.xively.com/v2/feeds/feed_id.json

where feedupdate.json contains:

{ "version": "1.0.0", "datastreams": [ { "id": "stream_id", "current_value": "202" } ] }

And I request the feed status like this:

curl -o feedrange.json -H Cache-control:no-cache -H Pragma:no-cache -H X-ApiKey:my_key http://api.xively.com/v2/feeds/feed_id.xml?start=2014-01-13T10:00:00Z

TIA.

RobM
  • 49
  • 6

1 Answers1

0

Nothing has changed on the Xively side as far as know.

That being said, I also noticed this problem recently. However, I was not able to reproduce it evenly. Try going to the feed in your browser, is it still cached? Try on a different internet connection, is it still cached?

My solution was to set the cache-control: no-cache header on the device, and this immediately took care of the problem for me. This is what I was going to recommend to you but it appears you are already passing that as a header.

I would recommend looking around at the other options you can set in the cache-control header and experiment with those. As well as try other devices and internet connections to see if you can figure out where it is being cached.

It would also be help me help you if you provided some info about what your setup is. Language, hardware, internet setup, etc.

calumb
  • 1,051
  • 2
  • 10
  • 24
  • Hi. As for my setup, I reproduced this problem using the Curl command line tool, as described above. None of the cache-control options seem to work. I've worked around it now by ensuring I request a different URL each time, by moving the start time on. – RobM Jan 17 '14 at 11:20