Getstatistic.jsp caching data server side?

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.

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

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.

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

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

1 Like

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.

But it is strange that:
https://pvoutput.org/service/r2/getstatistic.jsp?c=1&crdr=0&df=20210317&dt=20210317
provide:
11133,0,11133,11133,11133,1.776,1,20210317,20210317,1.776,20210317,0,0,0,0,0,0,0,0
which is old data but when c=0 it is ok
https://pvoutput.org/service/r2/getstatistic.jsp?c=0&crdr=0&df=20210317&dt=20210317
10696,6847,10696,10696,10696,1.706,1,20210317,20210317,1.706,20210317
Is it expected behaviour ?

If I remember correctly, passing different parameters will result in it recaching/recalculating the data. However, if you request the same parameters again, I think it uses the cached data. So it’s like there are multiple caches depending on what parameters you pass. That’s how I remember it at least, I could be wrong.

I think if you continuously have c=0 it will start to use the cached data. So the first time you request, it will look right, but I think after a little while it will be off.