Refreshing cache manually

Please consider this code. It reloads getdata() when I enter a certain date.

@st.cache(ttl=60*60*24)
def getdata():
    # download tons of data from Dutch government site
   df = /thedatadownloaded in a dataframe/
   global UPDATETIME
   UPDATETIME = datetime.now()
   return df, UPDATETIME 
def main(): 
     df_getdata, UPDATETIME = get_data()
     df = df_getdata.copy(deep=False) 
     until_ = st.sidebar.text_input('enddate (yyyy-mm-dd)',today)
     try:
         UNTIL = dt.datetime.strptime(until_,'%Y-%m-%d').date()
     except:
         st.error("Please make sure that the enddate is in format yyyy-mm-dd")
         st.stop()

     if until_ == "2023-08-23":
        st.sidebar.write("Clear cache")
        caching.clear_cache()
        until_ = "2021-01-01"
        st.sidebar.write("To start change a setting!\nChange the date afterwards!")

Consider the code above. It is made to manually empty the cache. If I enter the magic date and change an option, the reloading begings. But if I change the date after, it empties the cache and reloads the data again.

My questions:

  1. Why do I have to change an option? I would expect that the clearing of the cache starts at the moment that I enter the magic date and hit the button enter
  2. Why does it clear the cache again if I set the date back to the current date?

Complete code can be found here COVIDcases/covid_dashboard_rcsmit.py at main · rcsmit/COVIDcases · GitHub

The app is here https://share.streamlit.io/rcsmit/covidcases/main/covid_dashboard_rcsmit.py

Thanks in advance

I know already the answer on 1. It clears the cache, but it only reloads my data after changing a parameter.