Show and Tell - Server Side Caching

Hi @Emil,

In the documentation of ServerSideOutputTransform, you mentioned that

it is recommended to perform scheduled cleanups outside business hours

How can cleanups be scheduled? Will restarting the app cleanup the cache?

Thanks for your help!

The cleanup can be scheduled using you method of choice. It could be a cron job, and scheduled background task in Python, a task scheduled by Windows scheduler. The best choice depends on you infrastructure setup.

Sorry, can I clarify what does a cleanup entail? Deleting the files cached in the file system? How would something like that work when deployed to something like Heroku? I apologize for these questions as Iā€™m pretty new to the idea of caching. Thanks!

If you are using a file system store, then yes it would be deleting files. On Heroku, the file system is ephemeral, so I am not sure if manual cleaning is needed at all.

Hello everyone, iā€™m starting in dash and i fin usefull this dcc store concept, but iā€™m not pretty sure how to use in my codeā€¦ now i set this compenent in a div into the layout and the first callback (the tradicional callback) set and save the data here so like 10 callbacks (taditional callbacks) take the data and process this information in order to make graphs etcā€¦ but reading this article i guess that here i can find a better way in order to make faster the app executionā€¦ @Emil can you share a code, like at the beggining, explaining the method? i couldnā€™t find it in your git hub repo.

Thanks in advance

Yes, you can find documentation here,

1 Like

I am getting error ā€œAttributeError: ā€˜Outputā€™ object has no attribute ā€˜backendā€™ā€, i have used following syntax.What could be the reason

@callback(
    ServersideOutput("store-data", "data"), 
    ServersideOutput("store-data2", "data"),
    ServersideOutput("store-data3", "data", arg_check=False, session_check=False),
    Output("data_refresh", "children"),
    Output("container","children"),
    Output("client-id-store","data"),
    Input("refresh_button","n_clicks"),
    State("url","search"),
    State("client-id-store","data"),
    State("store-data", "data"),
    State("store-data2", "data"),
    State("store-data3", "data")
    , memoize=True)

Are there any gotchas for working with multi-page apps on Heroku?

Everything is working fine locally, but the

Input("DF_GLOBAL2", "data"),

on my Heroku instance returns None. Iā€™ve got a folder, file_system_store, on my app, and, again, it works fine locally. Iā€™m printing when I save it initially, and the dataframe prints correctly on the server;

@app.callback(ServersideOutput("DF_GLOBAL2", "data"), Input("dummy", "children"))
def run_first(inp):
    print("Saving DF Global")
    print(DF_GLOBAL)
    return DF_GLOBAL

But when I load it above, I end up getting None objects.

Are you using more than a single pod? And/or are you restarting often? I assume you are using a disk backend?

Itā€™s on gunicorn, 4 workers, and Iā€™m just using the default file store. I hope that answers all the questions. Sorry Iā€™m very weak on server side details

The instantiation of saving just looks like this:

@app.callback(ServersideOutput("global_df", "data"), Input("dummy", "children"))
def run_first(inp):
    print("Saving DF Global")
    print(DF_GLOBAL)
    return DF_GLOBAL

Any other thoughts on this?

There are a few possible issues. It looks like you might be using global variables? That can generally be a problem, so I would recommend to avoid it. Furthermore, disk caching on heroku can be problematic as the filesystem is local to the dyno (and ephemeral). If you only have a single dyno, the latter shouldnā€™t be an issue though.

A post was split to a new topic: Dash-extensions, ServerSideOutput error