dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: How do I prevent browsers from cacheing my swf?

  1. #1
    Junior Member
    Join Date
    Mar 2000
    Posts
    20
    I'm trying to create a private swf. How can I prevent my swf file from "cache - ing" in someones browser?

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    503

    CACHING

    As far as I know, it isn't really possible. Caching goes a little beyond browser specific functions (although the browser can be customized not to cache). Actually, all programs using the Win32 API to retrieve files off the net can optionally use the caching system provided by the OS.

    Of course, if you are adventurous....you can probably use ASP / CGI to deliver the SWF with the proper content type, and ASP / CGI page data isn't cached (well...at least not in the same way HTML is cached). Basically, you would have to read the SWF byte-by-byte with the ASP code and output it to the browser (and set the proper content-type, etc). Then, you would simply link to that cgi program instead of SWF. I've never seen it done, but you could try it. Still, there is no real "fool-proof" solution, just about anything can be bypassed.

    --Jesse

  3. #3
    Junior Member
    Join Date
    Aug 2001
    Posts
    2

    Beat The Cache

    I find that placing action script on the last frame of the movie allows the swf to refresh preventing a cache effect. It works for me...
    serk

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,804
    Edit your html code directly so the reference is for example: www.page.com/mc.swf change it to www.page.com/mc.swf?(some number and use a function that makes it random). Try it. see what happens when you add ?1 to the end of a page. You'll still go to the same page but the webbrowser will think that it's a different one and load it from source.
    .

  5. #5
    Junior Member
    Join Date
    Apr 2001
    Location
    L.A.
    Posts
    13
    I like that last suggestion, however could it be applied to a .TXT file that is being utilized by the SWF? ..so that the .TXT file 'DE-caches' each time the page is loaded?

    I use the following Actionscript to load the TXT in the first frame of the piece (it's a rotating banner header [not an ad]):

    if (base_url != null) {
    var dataPath = "/elements/swf/data/init.txt";
    }
    else {
    var dataPath = "data/init.txt";
    }


    Thanks kindly!

    Thanks kindly!
    Last edited by zornfett; 04-27-2006 at 03:37 PM.

  6. #6
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,804
    It's the same. In fact I can help you with flash. Like this:
    Code:
    if (base_url != null) {
    var dataPath = "/elements/swf/data/init.txt?"+random(999999);
    }
    else {
    var dataPath = "data/init.txt?"+random(999999);
    }
    The random number makes it unlikely to load it from the cache because of it hitting the same number again.
    .

  7. #7
    skylogic.ca MD004's Avatar
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    366
    Quote Originally Posted by swak
    The random number makes it unlikely to load it from the cache because of it hitting the same number again.
    If you want it truly unique you can use the Date object. You can even make it so that it loads the cached version only if it is on the same hour or day or year, etc. This way you can take advantage of the user's cache while still being a recent version.

    Code:
    myDate = new Date();
    dayOfMonth = myDate.getDate();
    Check your help files for all the other ones (getMinutes, getSeconds, etc)

    ~MD

  8. #8
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,804
    That works too.
    .

  9. #9
    Senior Member
    Join Date
    Apr 2006
    Posts
    1,059
    isnt there some PHP (or javascript) header that you can use to prevent the browser from catching?

  10. #10
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Quote Originally Posted by joran420
    isnt there some PHP (or javascript) header that you can use to prevent the browser from catching?
    There is but it's not reliable and somethimes ignored by the browsers.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center