How can I improve the page loading speed?

I need to load some large docx files in the page. Now the opening speed is very slow. How can I improve the page loading speed?

Have you tried using st.experimental_memo to cache the loading of the files?

I tried it. It didn’t work out so well.
My docx file is 30-40MB and takes about 20 seconds to load once…
Is there any better solution?

Hard to say in general – do you have some code you could share? What exactly are you doing with the docx file?

try:
    result = PyDocX.to_html(uploaded_file_path)
    stoc.from_markdown(result)
    os.remove(uploaded_file_path)

In fact, I am using this method to read the DOCX file once, but when the DOCX read exceeds 20MB, 30MB, or even larger, the DOCX loading of the page opened once is very slow, sometimes waiting for more than 30 seconds. What is a good solution? Thank you!

One think you can do is try to run the commands one at a time outside of streamlit (e.g. in ipython) locally (i.e. run PyDocX.to_html(“my_file.docx”) and time how long it takes to run, then try adding the stoc command, though that one may not work outside of a streamlit app). If it doesn’t work to run them outside of streamlit, you could just try running one command at a time and seeing how long it takes inside of the streamlit app. That might give you a good sense of what commands are actually the slow ones. The best streamlit will be able to do is caching slow functions so that they only have to run once, but it won’t be able to speed up the commands themselves.

Hey can you please tell me if your code supports formulas or not I need some help :slight_smile: