Is this the correct usage of memoize?

I’m using dcc.Tabs and had to refactor to display the content through a callback, as opposed to embedding it right into tabs’ children property. The later method has much smoother transitions since everything is loaded at the start, but it didn’t allow me to synchronize dropdowns across tabs.

I considered using memoization to make the transitions faster, but it doesn’t appear to make much of a difference. Below is how I have implemented it in my tab rendering callback. Is it correct? Is there a way to check if this is providing a performance boost?


@app.callback(Output('tab-content', 'children'),
              [Input('tabs', 'value')],
              [State('country-cache', 'data')])
def render_content(tab, country_cache):
    if tab == 'total-emp-tab':
        return total_emp_layout(country_cache)
    elif tab == 'temp-emp-tab':
        return temp_emp_layout(country_cache)
    elif tab  == 'agency-work-tab':
        return agency_work_layout()

And here is how I setup the cache as the start of the app:

app = dash.Dash(__name__)


server = app.server

cache = Cache(server, config={
    'CACHE_TYPE': 'filesystem',
    'CACHE_DIR': 'cache-directory'