Getstatistic.jsp caching data server side?


#1

I’m currently using /service/r2/getstatistic.jsp to get energy generated in watt hours for a range of dates, or for the current day. However, I’m noticing that if I pass the current date to date from and date to (df and dt), it sometimes caches data for the current day. For instance, I’ll make a request and it gives me statistical data that was valid 20 minutes ago, but not right now.

Is this a bug in the API, or is getstatistic not something I should be using for getting real time data? And if it’s not something that should be used for real time data, I think that there should be a note in the API specification that the server caches statistics and that it’s not real time like getstatus is.

I know this is not client side caching because I tested this on two different computers and get the same result. I also tried passing “Cache-Control: no-store” and “Cache-Control: no-cache” for my headers, but that doesn’t seem to do anything.


#2

For current data you probably should use today’s date for from and tomorrow’s date for to.


#3

I could do that, but that shouldn’t have an affect on the data I get back unless the system I’m requesting a statistic from has data for what my program thinks is tomorrow, which shouldn’t happen unless I get timezones or something wrong, which I know isn’t the problem because I’m using the correct date based on the system’s timezone.

I’ll probably end up using getstatus for this, but I might end up testing your suggestion and if that for some reason makes it stop caching data, I’ll have to decide between the two.


#4

Get Statistic provides summary data and is cached for 2-hours.

The cache is reduced to 15-minutes for donation enabled accounts.


#5

Gotcha, that makes sense. I think that should be added to the documentation.

Also, it would be nice if returned data could somehow indicate the last time the data was calculated/cached, but that would probably break someone’s program.