surveydown-dev / surveydown

Markdown-Based Surveys Using R, Quarto, and Shiny
https://pkg.surveydown.org/
Other
58 stars 8 forks source link

Survey rebuilt for every single visit: inefficient? #119

Open rgmerck opened 2 weeks ago

rgmerck commented 2 weeks ago

Bug description

Not sure if this is a bug or simply something that was not noticed before. I was trying to host surveydown locally as a server for testing, and as I was watching the server logs for multiple visits I was testing in different browser windows, I realized that surveydown actually rebuilds the survey from scratch from the quarto file at every single connection.

Is this necessary? Can't the survey be built once and cached afterwards for every new session connection? This has an impact on end users as they need to wait several seconds typically for the survey to show up, If the survey was cached, I imagine that this wait time would disappear.

Steps to reproduce

Run a survey on a local sever access the survey from different browser windows observe that the server process rebuilds the survey every time from scratch for every new visit

Expected behavior

survey would be built once, and cached visitor has close to no waiting time to see the survey

Actual behavior

new visitor has to wait 5 to 10 seconds to see the survey appear (potentially longer for a longer survey, too)

Your environment

Rstudio Ubuntu 24.04

jhelvy commented 2 weeks ago

Not a bug: https://surveydown.org/faq#why-does-my-app-load-slowly

If you have any suggestions on how to make the docs clearer on this, I'd appreciate it. We've got it in the docs and also in the FAQ page. The key is the use_html argument in sd_server(). We have it set to FALSE by default because if a user makes changes in their survey.qmd file but forgets to re-render it, then those changes won't appear in the resulting app. So with use_html = FALSE by default, we can guarantee that the latest changes in the survey.qmd file will always be included in the app. The tradeoff is that this default setting also means that by default the survey will load slowly, and we're relying on the user to find this in the docs to change it to TRUE. We could make it TRUE by default, but the user when then have to remember to always render their survey.qmd file when they make changes. As a user, any thoughts on this?