Is it possible to just update certain block after selecting an option from selectbot

Some blocks are not relevant to the option selected, but refreshing them takes time.
So the question is if it is possible to just update a certain range in the page instead of all the rest after the selecting?
Thank you :grinning:

Hello @Qing.Zheng, welcome to the forums.

In the Streamlit model, every time the app is refreshed through interaction, all of the script is run from top to bottom with the exception of cached functions. So a good use of cache is the way to prevent blocks of expensive computation from being run again.

For more advanced usage, there’s a (almost) official State hack if you want to store specific parts of your application state without revolving around the native cache functionality.

Could you provide a small snippet of your code (you can replace expensive functions by time.sleep(10000)) so we can see how to condition the appearance of a range of your page to those features ?


1 Like

Many thanks for the kind reply!
I used the cache when loading dataframe from disk. I would render a dataframe (around 8m) to the page. According to my perception, the data caching happens in the backend. So whenever rending a dataframe, the data needs to be sent from backend to the frontend which takes time.
In my case, an interaction actually only for the part of the page, the main big dataframe is not impacted, so no need to be transmit again.