Black Lives Matter. Please consider donating to Black Girls Code today.

Basic conceptual question on data sources

With a dashboard deployed, how often does it relook at the data source? Is the data source reloaded every time the chart is refreshed?

Unless you’re caching the results, the data source will be queried each time a callback is triggered. For my project, I’m using Flask-Cache and Redis to ensure that my data source isn’t pounded with the same queries over and over.

Sorry, I think I’m referring to something different!

Let’s say I’m hosting the my Dash application on a server (heroku/pythonanywhere), and make reference to a .xlsx file in the depository. If I upload an updated .xlsx file, I have to reload the application as Dash will not automatically retrieve the new information.

Is there any way to have Dash update automatically when a data source updates?

You can add an interval component, which triggers a callback that checks if the file has been changed (and if it has, updates the application content).

Thank you Emil, will check it up. It looks like something that will fit my requirements.

Edit for Updates on Page Load:

Having looked at it, it seems the gist is to set app.layout to a function, that returns app.layout

Why wouldn’t it work if I assign app.layout to variable abc, and have the function return variable abc?

Just exploring this, as it would make the Dash code cleaner, rather than assign the many nested html.Divs to the function…