Issue:
I have an issue with the long loading time when the app is accessed from a PC for the first time. It takes about 40s to load it in a browser. Then, when you let the app load completely and when accessed the second time, it shows up immediately. I tested it with Chrome and Firefox on three computers.
I believe that it is because the browser initially caches a lot of data. The app itself does not do any intensive calculations. Though I may be wrong.
My question is:
Is there a way how to reduce the time of initial data caching by, for example, reducing the amount of the data to be locally cached?
Hi,
I did the profiling. As expected, the longest time takes readRDS (1700 ms). However, this is not this issue. The app runs fairly quickly and smoothly when run locally on PC. The issue with the slow loading happens only when the app running on the server is accessed for the first time from a PC as I described above.
I can reproduce this waiting time only with a fresh chrome session. Edge and Firfox is working fine. Looking into Chrome's dev tools (performance tab) declared most of the waiting time as idle.
What happens in these cases is that upon a file not being found, the website serves an HTML page announcing that the file was not found. In these cases, the html is heavy with inline CSS, JavaScript, etc.
When images, scripts or other files fail to load, a simple HTTP 404 response should be served, and the large 404 html page should only be delivered when a webpage does not load properly. To serve a huge 404 page (or to just load the root page of your site) wastes data and server processing.
Hi,
based on your advice, I checked the performance. Then I realized, that the Shiny server automatically turns off the app when not used for 1 minute (default settings). Then, when accessed next time, a new R session is initialized which in this case means loading quite big .RDS files. The result is a long waiting time for the server response. So my initial guess that there is some connection with the data caching was wrong.
I solved the issue by turning the idle timeout off as described here or here.