Ten Image Display That Advances by Value Change on Server
I would like to display ten different images on my Website that are controlled by a value in a database.
Here is how I am currently doing it.
I created a function called "currentImage" to make a call to the database to see what the current image is set at. (e.g. numbers 1-10). That number is passed to the browser and stored as a variable called, "activepage".
I then have created a interval function that fires every 10 seconds. It calls the "currentImage" function which checks the DB to see if the current image has changed. If a change is detected then, the browser updates to the new image. If not, it stays the same.
This 10 second call happens as long as the browser is open.
Can This Change be "Pushed" by the Server?
What I am wondering if there is any way that the server could "push" this value to the browser and be accepted without the operator having to acknowledge the push (e.g. that's why I don't believe push notifications will work.)
Heavy Server Load (or is it?)
The above option works fine and it may be the only way. The problem is that let's say a person has their browser open for 10 minutes to watch the images (e.g. like a presentation). Ten minutes is 60 database calls. If 100 people were on the site at the same time that would be 6000 database calls in ten minutes. Maybe that's not a lot, but it seems to me like it is.
One Time Acceptance Okay
I am okay with a one-time acceptance of the user at the start. In other words upon arrival, a box pops up that says, "I give permission to allow my screen to be updated." But then all subsequent refreshes happen without user intervention.
Bottom Line: Is there a way to do this?
So bottom line, is there any other way to do this other than the client browser making the DB call every 10 seconds?