I have a cache issue. In my app I allow the user to upload a file and can do a bunch of things. When the app is deployed to Streamlit cloud what I notice is the file uploaded by say user #1 remains in the cache and when user #2 uploads their document it has no effect and only user #1’s document is used. I want to clear the cache programtically before the uploaded file is processed. How can I accomplish this?
def clear_submit(): st.session_state["submit"] = False #st.cache_data.clear() placeholder_upload = st.empty() with placeholder_upload.container(): uploaded_file = st.file_uploader( "Upload a pdf, docx, or txt file.", type=["pdf", "docx", "txt", "csv"], help="No scanned documents please!", on_change=clear_submit, ) TABULAR_INPUT_FILE_FLAG = False index = None doc = None if uploaded_file is not None: if uploaded_file.name.endswith(".pdf"): doc = parse_pdf(uploaded_file) #st.write(type(doc)) elif uploaded_file.name.endswith(".docx"): doc = parse_docx(uploaded_file) #st.write(type(doc)) elif uploaded_file.name.endswith(".txt"): doc = parse_txt(uploaded_file) #st.write(type(doc)) elif uploaded_file.name.endswith(".csv"): TABULAR_INPUT_FILE_FLAG = True doc = parse_csv(uploaded_file) st.session_state["api_key_configured"] = True else: raise ValueError("File type not supported!")