Hi all, it's possible to have a js script that checks repeatly, say once each 5 secs, the last modified date of an image file on the server and, if changed, reload the page or update the page with the new image?
Hi all, it's possible to have a js script that checks repeatly, say once each 5 secs, the last modified date of an image file on the server and, if changed, reload the page or update the page with the new image?
Thanks.
Are you paying for the bandwidth yourself?
I'm not positive, I am new to Javascript. but, Your browser caches the image locally. I believe that even IF you are able to find that the image was a new image, the fact that the image has the same name as the old means that the browser will see that the names are the same, and use the one from local cache.
You can force a reload on the intire page, again increasing your bandwidth.
I think you may be better off naming the the files in sequence, imagefile000.pn g, then while using the 000 file see if 001 exists, and if so change the src in the DOM element and reload the new image.
Then change the currentindex in your java script to begin looking for 002.
Thanks for the suggestion, I'll surely try it.
I expect it to change each 5 minutes in normal situation.
The image shows the situation of a Wi-Fi network and, depending on the state of the network it could change even more often.
Originally posted by hdanw
Are you paying for the bandwidth yourself?
I'm not positive, I am new to Javascript. but, Your browser caches the image locally. I believe that even IF you are able to find that the image was a new image, the fact that the image has the same name as the old means that the browser will see that the names are the same, and use the one from local cache.
You can force a reload on the intire page, again increasing your bandwidth.
I think you may be better off naming the the files in sequence, imagefile000.pn g, then while using the 000 file see if 001 exists, and if so change the src in the DOM element and reload the new image.
Then change the currentindex in your java script to begin looking for 002.
Why are you using the image in same url for two different states? Make different images with different urls, and just change <IMG> src based on current state of wifi. (this way you can call some page that will tell you what is the current state of wifi by XMHLHttpRequest and change image).
But if it is not acceptable (you are generating some additional information into image file). You can always force browser to ask for new image by adding some additional parameters into url (call http://www.images.com/myimage.jpg?ver=1 for the first time and and change it to:http://www.images.com/myimage.jpg?ver=2) - As you can see it will refer to same image file, but different url will force browser to download new one :) (you can use some kind of timestamp for the variable or so)
Comment