As I search for a way to automatically update my webpage with fresh data from the server, I am faced with uncertainty regarding the frequency of these updates. The intervals could range anywhere from every 10 minutes to an hour, which makes it challenging to predict. It is crucial that any changes are reflected promptly on the screen, ideally within 15 seconds.
One approach is constant polling at 15-second intervals, but this may lead to sending numerous empty requests if new data isn't available for an extended period, which seems inefficient.
Alternatively, employing long-polling raises questions about keeping connections open for prolonged durations and handling scenarios where there's no new data for up to an hour. Setting timeouts becomes necessary, yet terminating connections prematurely due to inactivity conflicts with the purpose of maintaining real-time updates. This might essentially revert us back to regular polling with longer intervals.
I would greatly appreciate guidance on choosing the optimal solution for my predicament. Thank you in advance!