logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: HTML image refresh limits without Page Refresh
Author
MacDawg



Joined: 25 May 2018
Posts: 2
Location: USA, Atlanta

PostPosted: Fri 25 May '18 19:57    Post subject: HTML image refresh limits without Page Refresh Reply with quote

Newbie here

Use case: running web server for digital signage (restaurant menu boards)

Running Apache 2.4 on Windows 2016 Server (IIS disabled)

Using the following HTML Code to refresh an image without a page refresh

Code:
<script language="javascript">

function updateImage() {

   obj = document.imagename;

   obj.src = obj.src + "?" + Math.random();

   //Following statement sets the delay before the function will

   //call itself again (in milliseconds)

   setTimeout("updateImage()",300000);

}

</script>

<body onload="updateImage();">
<img name="imagename" src="image.png" style="position:absolute;top:0;left:0;height:100%;width:100%" />


Code works great and allows a hot swap of image with same name without page refresh
The current code is set to refresh the image every 5 minutes
However, it will show a broken image icon after about 480 refreshes or so [roughly, not exact]

In other words, if I set the refresh rate at every second it will break the image in about 8 minutes
If I set the refresh rate at 5 minutes it will break the image in about 40 hours
Interestingly, same HTML code on IIS will break the image much quicker > 1 second refresh breaks in about 1 minute and :48 seconds

Which leads me to believe this is possibly a setting [or limit] in the web server software?
What I would like to know is, is there a setting I can change to increase the number of refreshes or set to unlimited?

I know I can do a scheduled auto refresh of the page to start the clock again, but would like to avoid the page refresh "flicker" on digital signage

I've Googled and haven't found anything helpful in addressing this, so any thoughts would be appreciated

Thanks!
Back to top
MacDawg



Joined: 25 May 2018
Posts: 2
Location: USA, Atlanta

PostPosted: Sat 26 May '18 19:50    Post subject: Reply with quote

SOLVED: I found my own answer

After digging deeper and debugging I found what my real issue was
My code below was appending the random number every time it updated
This caused the name to grow and eventually created an error: Error 414 (Request URI Too Long)

Code:
   obj.src = obj.src + "?" + Math.random();


To correct this, I had to add a split to the code (and I went with date/time instead of a random number, although either would work

Code:
   obj.src = obj.src.split("?")[0] + "?" + new Date().getTime();


Now the setTimeout loop runs indefinitely without error
Back to top


Reply to topic   Topic: HTML image refresh limits without Page Refresh View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner