Multi-Page Dash App with dcc.Store

I have a multi-page application that utilizes data imported from a mongoDB. Home page has the ability to view, filter, sort, and update the data in a dash datatable format. The report page allows the user to enter inputs in order to add a new entry to the dataframe/datatable. I am using dcc.Store with session storage in the file to share the data between pages/callbacks.

The issue I am having is that in order to make my application suitable for deployment, the initialization function that downloads the data from mongoDB must be contained within a callback on the home page. This leads to the initialization function being called every time the home page is navigated to, essentially clearing any data updates done within the app by redownloading the database data.

I need a way to download the data only once on app startup, but update that data saved on the dcc.Store component from different pages of the application.

Potential solution: although not well documented, callback triggers in the main file are permitted. Trigger a callback here that runs on initial load to load in the data. That allows the function to not be triggered every time a page loads, but still share the data between all pages.


Correction, this solution still leads to the initial download firing multiple times based on how many gunicorn workers I have and how I navigate the pages…