Gspread together with streamlit is extremely slow

Hi @dataprofessor, thank you for the quick reply!

I tried setting st.cache_data before the function but it behaved the same, except for the spinner.

I need the code to be independent from Streamlit, I only use it to display some things with some controls, so using a Streamlit specific solution for google sheets wouldn’t work unfortunately.

However, since I thought it might be some network issue I tried switching to a mobile connection instead and then it worked immediately! The wifi otherwise works fine and is fast, and it’s only gspread that is affected by the slow speed, I’m using pymongo in other parts of the code and that works fine regardless if I use wifi or something else. I found this thread where they seem to have the same or similar issue https://discuss.streamlit.io/t/i-am-not-able-to-access-my-app-when-using-wifi-network/38033

What could I do?

Edit:
I just tried using a VPN and that makes it work as well. Do I need to change some network settings to make it work on regular wifi?