A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 27

Thread: How to prevent caching of swf files

  1. #1
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973

    How to prevent caching of swf files

    Last edited by Incrue; 04-17-2005 at 09:14 AM.

  2. #2
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    as it says there:
    "SWFs, like other documents and media retrieved by a Web browser, are often saved, or cached, locally on the user's hard drive. The next time that media is requested the Web browser may load the file from the cache instead of downloading it over the network. This might be desirable for a Flash movie whose content doesn't change often but undesirable for SWFs that are updated frequently with new content or information."

    so in return it doesn´t make that much sense not to cache games which normally don´t have changed content each time.
    i guess the reason why you want to avoid caching is to achieve protection of your content against theft.well,disabling swf caching doesn´t help that much there as there are several other ways to grab a swf if someone wants to.
    on the other side disabling caching means exploading traffic for you (if you have a paid host more costs,if you have a free host quickly exceeded bandwidth quota) and a negative game experience for your game player (as he has to load the game each time though he wouldn´t need to).

  3. #3
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    Originally posted by tomsamson

    much there as there are several other ways to grab a swf if someone wants to.
    "divide to conker"

  4. #4
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    hm,yeah,generally doing many different things to protect your stuff may seem like a good idea but in this case i think the negative side effects heavily outweight the minimum advantage you gain on the protection side

  5. #5
    CRT Boy mclelun's Avatar
    Join Date
    Dec 2002
    Location
    happy land
    Posts
    299
    hmm actually, i know director can embeded flash in it. but can director be decompile and extract the swf out?

  6. #6
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    Mcleun,we already talked about this, search the board for "flash + director for security"

    Tomsamsom, so, what are the other ways he can get the swf?Knowing his name and typing in the browser window?

    I ask myself, if people can play it in cache, why they would need to go to my site, anyway?
    Last edited by Incrue; 04-17-2005 at 12:47 PM.

  7. #7
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    hm,there are several ways to get files from a server,no need to list em all i think.
    the casual gamer will probably more like to just visit a site and play the game rather than going to his cache,looking for all files connected to a game and the get it working on his machine.
    yeah,thieves will do that or other things but éven if protecting your stuff is important to you i´d choose working on the product itself and giving your adience a good feel rather than focussing on protecting your stuff in a way which is negative for your audience.
    better concepts for protecting your stuff are splitting it into several files in different folders,using obfucators for the code and loading small files like map files each time on runtime if you want to do that

  8. #8
    CRT Boy mclelun's Avatar
    Join Date
    Dec 2002
    Location
    happy land
    Posts
    299
    ohh sorry my bad, too long never visit this forum, didnt know it.

  9. #9
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    Tom, please check your PM

  10. #10
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    Rigth, i got your point
    But, what if...the swf is not in my site, anyway?If i have a php who conects to my other server trough ftp, ( in wich the swf is in), copy the swf, paste in my first server, send it to the browser and them delete the swf?

  11. #11
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    This thing is not working...
    Anyway, i should not worry about this
    Today we have flashincrypt, all he has to do is hide the url check and there will be no more problems at all

  12. #12
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016
    as well as using pragma no cache and expired tags, there is another way.

    If you have a high score table for example retrieved from a DB using PHP (or whatever), you might make a call like this:

    Code:
    loadVariables("highScore.php?list=10","0");
    but as flash may use this several times inside a movie, you may receive cached data rather than the freshest stuff available so I use this

    Code:
    unique=new Date().getTime();
    this.loadVariables("highScore.php?list=10&unique="+unique);
    This then adds the current date and time as a parameter (which is largely ignored by my PHP script but means that it will never be the same as previous calls to the script and therefore never cached.

    I have used this quite a bit in the past and I believe it originally came from Flashgurus site but I can't find it again.

  13. #13
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    I was thinking about what Tom and Lapo sayd and came up with this weird idea:
    1. Have your game splited between many swf to be loaded dynamically.One of them has just the code, and this is the main swf cos he is the one who runs the entire game and who loads the other swfs.As he have only the code he may not be that heavy, i gess...

    2 Find a way to let all of the other swfs in cache, but the main.swf is taken by my php in other server and sended to the browser with no cache

    I gess it may solve those bandwith stuff and also prevent someone to take the main.swf from my server, since they dont know the adress of my other server

    BUt this pragma and header stuff are not working...

    RazorMedia, this stuff can send a secret variable to inside the swf?I mean, it can be used to load some variables inside flash so that noone will NEVER see those variables,(cos they dont end up in cache)and to do this i must load the php two times, and make the variables only came if is the first call, am i rigth??
    This parametter stuff would also work too if i want to call swfs but not phps?

  14. #14
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Incrue, why this big hang up about protecting your games ?
    In the grand scheme of things it's not that important. If your games are for clients, then you're getting paid anyway.

    RazoRmedia's example is just a simple cache killer, I usually just add a random number to it rather than the time. It's a way of forcing an up to date response from the server, so it's handy for things like hi-score files and constantly updated xml.

    I'm assuming you use FireFox ? If so, grab the essential Live HTTP Headers extension and see exaclty how un-safe everything is ( Again with Firefox, go to a page with a swf, then from the Tools menu select Page info and then the media tab. Grabbing files and seeing what data is passed is so easy it's untrue ).

    To be honest mate, I'd rather see some great games from you rather than you beating yourself up over protecting things.

    Squize.

  15. #15
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016
    sorry, mine wasn't a protection thing, rather a tool to ensure the user gets the most updated content when loading from external files.

    must remember to read through posts fully before opening mouth

  16. #16
    Custom User Title Incrue's Avatar
    Join Date
    Feb 2004
    Posts
    973
    Squize: Thanks for the feedback, i saw how firefox could show that...i think i was getting obsessive about this protection stuff, and giving me headaches...
    Yeah, you are rigth, i should focus in build something...

    Lapo: Dont worry about you sayng the wrong thing; to mee what you sayd could be used to lots of goals

  17. #17
    curiouser and curiouser LittleRed's Avatar
    Join Date
    Mar 2004
    Location
    Nottingham
    Posts
    335
    is there a way to use the technique that RazoRmedia mentioned to stop ordinary txt and xml files that are loaded into the swf from being cached?
    (I'm using sendAndLoad if that impacts on the technique at all)

  18. #18
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016
    Originally posted by LittleRed
    is there a way to use the technique that RazoRmedia mentioned to stop ordinary txt and xml files that are loaded into the swf from being cached?
    (I'm using sendAndLoad if that impacts on the technique at all)
    yes, course there is, if you're using sendandload, simply use the code below in much the same way to create a unique identifier which will be sent.

    Code:
    unique=new Date().getTime();
    
    var bruce = new LoadVars();
    var xmlRec = new XML();
    
    xmlRec.onLoad = function()
    {
    trace( this );
    }
    
    bruce.sendAndLoad("highScore.php?list=10&unique="+unique, xmlRec , "GET");

  19. #19
    curiouser and curiouser LittleRed's Avatar
    Join Date
    Mar 2004
    Location
    Nottingham
    Posts
    335
    thanks for the reply.
    sorry if I'm being dense, but I'm not quite following how this prevents caching.
    This method sends a unique variable through to the receiving php script, but how does this affect the text file that the php saves?
    If I load the text file back in, do I need the unique identifier to ensure that this is the most current version?

  20. #20
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016
    it prevents caching via the following:

    If I use

    bruce.sendAndLoad("highScore.php?list=10", xmlRec , "GET");

    then it requests data from highScore.php and returns it. If I do this a number of times, as the data has already been returned, it could deliver cached data and not the latest data.

    If I send the unique identifier as below, it will always send a 'new' request and therefore the latest data would always be returned.

    bruce.sendAndLoad("highScore.php?list=10&unique="+ unique, xmlRec , "GET");

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