For example, when you load a dashboard, you are presented with all the current table result data from the widgets there.
If those widgets are queries with a scheduled refresh rate, even if that query refreshes on schedule, the widget contents does not update on the dashboard. To see the latest results, you must either reload the entire page, or refresh the dashboard causing every single widget to re-execute (potentially unnecessary load).
It would be a nice feature if, upon a query updating especially through its own schedule, the dashboard client-side page automatically detected this and simply fetched the new result contents. This would enable us to have an updating dashboard view of various widgets including expensive to calculate but not often changing results.
The other problem this feature would solve is when people leave a dashboard open in a browser tab, and they end up with stale information without realising it. Since we are already doing AJAX style reloading, this feels out-of-odds with Redash’s other features.
This should be possible with the existing query results API. It supports a max_age parameter when fetching cached query results. If a cached result is available and is newer than max_age seconds, the cached result is returned.
Today, when you click to refresh a widget, the web application sends a request to the query results API with max_age set to 0. This guarantees that a new execution will commence.
But if you set max_age on this request to 300 and a cached result was saved within the last five minutes, the cached result will be returned immediately.
Today, there is no system for signalling the front-end when a fresh result is available for a query. But you could perhaps accomplish this behaviour by manipulating the max_age behaviour. Alternatively you could modify the back-end API to include a flag that says “give me the cached result no matter how old it is”.
Wouldn’t it make sense to use the max_age value on the query results API calls from the dashboard, so that if for example you want to refresh every 5 minutes, it only triggers re-execution of queries that have results which are more than 5 minutes old?