Results 1 to 4 of 4
  1. #1

    XML Playlist Cache Prob, Possible Workaround?

    Hi,

    I downloaded your excellent media player yesterday - it looks to be just what I'm looking for

    However, I did have a problem with the XML playlist which was caching everytime. This was a particular problem as I was setting up the playlist at the same time as R'ing TFM so any changes I made weren't showing unless I cleared the browser cache.

    After a little head scratching, I came up with a solution of sorts, which is to append a random string of characters to the playlist filename in the js as a query string, which seems to do the job.

    Bizarrely, the first "random character string" javascript function I came across on google was also from this site although I changed the end of it to return the value instead of writing it to document.

    Code is as follows;

    // I placed this below the main comment block at the top of the js file, before the variables are set
    function randomString() {
    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
    var string_length = 8;
    var randomstring = '';
    for (var i=0; i<string_length; i++) {
    var rnum = Math.floor(Math.random() * chars.length);
    randomstring += chars.substring(rnum,rnum+1);
    }
    return randomstring;
    }

    ... then ...

    playlist = "myplaylist.xml?foo="+randomString(); // Random query string to stop XML caching

    ... I would appreciate any thoughts on this as a suitable method, or there may well be simpler methods that I haven't considered...

    Note to other users - I have only tested this on my setup, and it has not been peer-reviewed yet. Edit js files at your own risk!

  2. #2
    Administrator Dave's Avatar
    Join Date
    Sep 2004
    Location
    Te Awamutu, New Zealand
    Posts
    3,959
    Blog Entries
    79
    Quote
    Quote: nigenet
    I downloaded your excellent media player yesterday - it looks to be just what I'm looking for
    Excellent.

    Quote
    Quote: nigenet
    However, I did have a problem with the XML playlist which was caching everytime.
    Yeah, I've noticed that as well. It doesn't usually bother me except when I'm working on something and I want to keep changing the playlist. I think your solution is a good one. I have used a similar solution before to prevent image caching and it works well. I can't see any reason for it not to work with the media player. Good thinking

    Quote
    Quote: nigenet
    Bizarrely, the first "random character string" javascript function I came across on google was also from this site
    hehe, our domination of the Internet is almost complete. Soon there will be no need for other websites.
    Dave Owen
    MediaCollege.com

  3. #3

    playlist caching

    nigenet, it works for me here too. Thanks. Only thing now, it takes a little while to load the playlist but that has to be expected.

  4. #4
    New Member
    Join Date
    Jul 2009
    Location
    Cleveland, Ohio. USA
    Posts
    4
    works on Safari and FireFox for Mac, too. Thanks!

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
  •  
Subscribe to us on YouTube