Clear cache

I have been fighting with the cache function of Streamlit literally for days, and still am not able to achieve what I want.

I want to achieve the following:

  1. On page load, load a dataset and cache it, so that next time when you load the page the dataset is retrieved from the cache
  2. Click on a button to update the dataset so that it is refreshed manually with the latest information

How do I achieve this? This simple use case seems almost impossible to achieve. Help?

Hi @mmcnl -

This forum post sounds like what you are trying to do:

Ultimately, the cache function uses the function inputs to determine whether the data already exists in cache to be served. So you need to do something like pass a timestamp or other method of unique keys to your load data function, so that when you hit the button it passes a new value to your function.

Best,
Randy