Multi-page app: prevent page refresh

Hey - I have a multi-page app, where the main page is a dash-leaflet map and another tab where I display the data. Trouble is, when the user goes to “data” tab and back, the map is refreshed. It can be expensive, plus information about the previous location is lost.

I tried to extend the component with Persistence of center and zoom, but the map still gets refreshed.

Is there any way to indicate that the page should not be refreshed upon navigating to it? I don’t want all the callbacks to fire.

Here’s my setup in brief:

app = dash.Dash(__name__, use_pages=True, prevent_initial_callbacks=True, external_stylesheets=[dbc.themes.BOOTSTRAP], external_scripts=[chroma], background_callback_manager=get_background_callback_manager())

content = html.Div(id="page-content", style=CONTENT_STYLE)
app.layout = html.Div([dcc.Location(id="url", refresh=False), sidebar, dash.page_container])

I hoped the refresh=False will do the trick, but no luck. The background_callback_manager is DiskcacheManager, I am also using gunicorn, but i guess that does not matter.

1 Like

Could you post a complete MWE demonstrating the issue? That may help people debugging :slight_smile: