SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Apr 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    script so webcam image doesnt cache?

    Hi,

    I have a direct link on my website to a webcam which updates every hour. However my browser seems to cache the old image locally if I go back onto the site later.

    Is there a simple script I can add to the image address that will somehow randomise the image so it grabs the new one each time?

    I'm sure Ive seen this somewhere before but cant find a simple solution.

    many thanks in advance

    Muddy

  2. #2
    SitePoint Guru alecrust's Avatar
    Join Date
    Jun 2007
    Location
    London, UK
    Posts
    728
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is the image loading as a background image? In most browsers background images aren't re-fetched and instead are loaded from your cache. If this is the case, is there a way you can make it a simple <img /> tag instead?

    If not, see if this works if you add it to your <head> section:
    Code:
    <meta http-equiv="pragma" content="no-cache" />
    Honda Civic Forum - UK Civic Forum
    Web Host Reviews - Independent, honest host reviews
    My Portfolio - Simplicity is the ultimate sophistication

  3. #3
    SitePoint Member
    Join Date
    Apr 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, it's not a background image, but I'll try the cache meta tag.

    cheers!

    Muddy

  4. #4
    SitePoint Member
    Join Date
    Apr 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The cache tag doesnt seem to work.

  5. #5
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can try to add a random query string to the URL of the image, something like this:

    Code:
    var myimageURL = 'http://www.example.com/theImage.jpg';
    myImageURL += '?foo=' + Math.ceil (Math.random () * 9999);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •