I have a non-interactive Shiny app hosted on RStudioConnect that is persistently displayed on several monitors. I am wondering if there is a way to configure the app so that each client instance of the app automatically refreshes whenever a new update is deployed to RSConnect?
This is a fantastic question! I presume you have set many of the timeouts to 0 so that the application is displayed consistently on the monitors without timing out?
What behavior are you seeing currently? Does the old version of the application continue being displayed when the new version of the application is deployed? I definitely would have expected the new version to get rolled out to clients!
The new version of the app will be available to new sessions, but old sessions will still get the older version of the app. An easy way to fix this is to occasionally refresh the clients. As @Cole mentioned, you can tweak the timeout settings to determine how often a client is disconnected.
Is the refresh due to new data? Or are you concerned about structural changes to the app?
I'm concerned about structural changes to the app itself. The data updates regularly via reactivity and is handled via Shiny. However, I am wondering if there is a simple way to enforce client refreshes when an updated version of the application is published to Connect? Disconnecting the user is not ideal, since these applications will be displayed 24/7 in a non-interactive setting (on TV's without user input).
Since the client will not be disconnected by Connect (per @slopp's comment), it seems to me like your best bet will be to throw something in the front-end of the application that triggers refreshes after a given period of time. I.e. you could make the app hard-refresh every hour, every 6 hours, etc.
Ultimately, it is unfortunate that this does not give you guarantees of when / how soon after an update the app refreshes, but it does give you the automatic refreshes (on a configurable timeline) without manual intervention.
WARNING: untested The below JavaScript, for example, forces the page to reload every 4 hours (1000 milliseconds * 60 seconds * 60 minutes * 4 hours)
function reload_page() {
window.location.reload();
setTimeout(reload_page, 14400000);
}
setTimeout(reload_page, 14400000);
There may be a way to do this from R as well
I suspect there is a way to make this more "savvy" and "detect" changes to the active bundle on Connect, but I suspect the added complexity / fragility is not worth the effort. Writing JavaScript can be painful
You definitely don't need the shinyjs package to make this work, but it does make things a little easier Throwing the JavaScript into your HTML as a script tag, etc. would work just as well.