🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

Show and Tell - Server Side Caching

Hi Emil, this feature is awesome - thank you so much for creating it! I have a small question - why is the drawback of this approach: “you cannot use client side callbacks as they will only be able to access the key”.

Since the data is never transferred to the client, it cannot be used in a client side callback :slight_smile:

1 Like

Hi there

I’m interested in using your package as I need some server side caching of data and serverside rendering too. Do you have any plans of creating a version that can be installed with Anaconda? Thanks!

I don’t use conda myself, so i didn’t consider a conda release. Is there a reason why you can’t use pip?

How do you set the threshold when using DashProxy'? It doesn't like output_defaults. I'm using the transforms, when I use dash_extensions.enrich.Dashit complains about having multiple values for keyword argumenttransforms. I have many ServersideOutput`s so I prefer to define it globally instead of inside each callback.

If you use the DashProxy object, you can pass the keywords to the constructor of the transform itself,

app = DashProxy(transforms=[
    ServersideOutputTransform(backend=mybackend),  # enable use of ServersideOutput objects
])
1 Like

Hi @Emil !

Many thanks for your contributions. Im finding this really helpful.
Do you know how I could use a RedisCache for caching with dash-extensions? I am using the latest version of dash-extensions. Or should I go to dash-extensions==0.0.23 which allows any flask caching backend?

Thanks,

@ljam

Thanks! I would recommend using the newest version. It should be realatively easy to implement a Redis binding. Here is the file system implementation,

Hi @Emil ,

Thanks for the tip! Ill try implementing this :slight_smile: and is it works well, i might consider adding it in a PR request

I added a simple Redis binding in the latest release. You can try startnummer with that one :slight_smile:

1 Like

Hey, Love this concept, Ive gone to test it out and I get a problem due to my main callback also needing a daq.BooleanSwitch however this cant be pickled. Any advice on how to get around this?

Can you post a MWE demonstrating the issue? Why can’t it be pickled?

Update: I found the issue, it was that the callback I use to cache data also output the required layout (which contained the BooleanSwitch Method) after splitting out the data caching and layout selections this now works :slight_smile:

Strange I cant seem to reproduce it in a MWE, but the actual error is “_pickle.PicklingError: Can’t pickle <class ‘BooleanSwitch’>: attribute lookup BooleanSwitch on builtins failed” if that helps?

Hi Emil,

Another issue I’m running into with this is using the @cc.cached_callback where I’m outputting data to dcc.Store but also trying to get the current State of that id. see MWE below, when I try to execute this the error I get is TypeError: object supporting the buffer API required.

Any idea on how I can get around this?

@cc.cached_callback(
    [
        Output('df_history', 'data'),
    ],
    [
        Input('url', 'pathname')
    ],
    [
       State('df_history', 'data'),
    ])
def store_data(pathname, df_history):
    if df_history is None:
        <make dataframe here>
        return dataframe 
    else:
        raise PreventUpdate

It seems like you are using an old version? The cached_callback syntax was deprecated some time ago.

Thanks for the info, in your original post you were using the cached_callback, would you be able to share any documentation on how this server side caching should now be implemented?

Up-to-date examples are available in the examples folder on github, e.g.

1 Like

Hi @Emil ,
I’m beginner to plotting. I’m trying to integrate dash with Flask and I have this error.
Could you help me?
dash : ‘1.21.0’
dash-extensions==0.0.23

Hi Emil,
I have tried ServersideOutput. It works fine. But sometimes, some of my charts get this error: cannot import name ‘ValidatorCache’ from partially initialized module ‘plotly.validator_cache’. Do you know what that is?

I don’t think that is related to the Serverside output.