Multi Page Dash App with Cache - One Page Per File Structure

Hello!

I am following the example in the documentation for creating a Multi-Page App with one page per file. I am wondering how I should share a cache between pages.

Cache is created in app.py

cache = Cache(
    app.server,
    config={"CACHE_TYPE":"FileSystemCache"},
)

And for example in page1

@cache.memoize()
@callback(
    Output('page-1-display-value', 'children'),
    Input('page-1-dropdown', 'value'))
def display_value(value):
    return f'You have selected {value}'

But to get the cache from app.py I would need to import it which causes a circular import.

How do I share the cache object to the other pages without introducing circular imports?

Hi @prokie - welcome to the dash community :slight_smile:

You might find this post helpful: Load data once and retrieve in multiple pages - #4 by AnnMarieW

Thanks for quick reply!

Yes, get_app() will solve my issue.