Search code examples
.netsql-serverangularcachingpolling

Database Polling from Multiple Browser Tabs


I am working on a .NET/angular application that polls SQL Server database for recent updates. This setting is configurable by the user from 10 seconds up (it was a business requirement). The problem is that every time a user opens a new tab, it does its own query against the database. So if a user has 10 tabs over, there are going to be 10 requests going in every 10 seconds to the DB and back. How can I perform database polling with some sort of caching, so that multiple tabs or windows don't make any additional round trips. What is the best approach?


Solution

  • You can save your last polling-date inside the LocalStorage, and do a check inside your polling interval, if it's older then x seconds. Little bit of dirty workaround, but my best idea :-)