What are the best options when caching large Dash datasets through Django?

Has anyone managed to cache data using Django framework? I’m going to be using Redis, but I see that there are also other options. Writing out Javascript to cache in the frontend (I don’t know how to code in JS), using Flask caching (would this conflict with Django?).

I have large SQL queries that I would like to cache, trying to figure out the most successful methods people have using during deployment & production, specifically related to Django. I also plan on using Docker which is why I will be using Redis.

We built django-plotly-dash in order to serve Dash apps from within Django applications. We did approach this from a ‘Django-first’ direction, in that Django is managing the data and providing the server infrastructure, and the embedded Dash functionality providing part of the front end.

1 Like

I love your open source project, thank you so much, it has helped me go far in building my dashboard. I would still have to implement the procedures to cache data, what would be the best options in your opinion? How well does Flask Cache library preform when combined with django? Sorry for the noobish questions…

@andres1 its hard to make specific recommendations, but in general I’ve found that using Django’s built-in caching is more than adequate, and also integrated with other components that you might use from the Django ecosystem.

Putting as much as possible into ‘pure Django’ (ie not inside a Dash callback) also helps a lot; it sounds like your interest in caching means that you’re effectively heading in this direction already.

@delsim do you have any caching examples on how that might look like for a single graph callback (the data) in Dash-plotly-django?

There is a section in the documentation covering the examples that form the demo application in the project’s source code repository.

The views uses to render the dash apps, and also the callbacks, are called in a similar environment to other Django views, so all of Django’s features such as the ORM, caching, etc are available to you.