473,396 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Javascript lastUpdatedDate

18
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.
Feb 6 '08 #1
3 1121
hdanw
61
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.png, 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.

How often do you expect it to change?
Feb 6 '08 #2
Ciri
18
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.

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.png, 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.

How often do you expect it to change?
Feb 6 '08 #3
Dasty
101 Expert 100+
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)
Feb 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phil | last post by:
I created a custom profile provider based on the example here : http://www.theserverside.net/articles/showarticle.tss?id=CreatingProfileProvider It works ok, but when I try to get the last update...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.