1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Force content refresh +rep for help!

Discussion in 'Programming' started by okgaz, Jun 26, 2007.

  1. #1
    Hi,

    I want to force an swf file on one of my website pages not to load from cache.

    If it loads from cache it does so incorrectly.

    Any ideas how to do this?

    + rep for anybody who helps!

    -Gaz
     
    okgaz, Jun 26, 2007 IP
  2. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can add a random number to the location of the swf. This way the browser sees it as a different url. Here's a php code that do so:
    <embed src="myflash.swf?<?php echo md5(microtime()); ?>"></embed>
    PHP:
     
    UnrealEd, Jun 28, 2007 IP
    okgaz and neroux like this.
  3. okgaz

    okgaz Well-Known Member

    Messages:
    450
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Thanks for the response :)

    That's a good idea but unfortunately I don't think it will help as I'm already using .swf?variable= *string here*

    The very problem is that until I refresh the page the variable won't show up in the flash movie. ie. the page loads and the movie plays but the movie doesn't recieve the variable until I hit refresh, loading the whole page again :confused:

    Here is an example of the flash embed I'm using (which is generated using php like in your example).

    
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0" width="550" height="400">
      <param name="movie" value="http://www.sitename.com/swf/demo.swf?gazcode=1aa1ba1ca1da1ea1fa1ga1" />
      <param name="quality" value="high" />
      <embed src="http://www.sitename.com/swf/demo.swf?gazcode=1aa1ba1ca1da1ea1fa1ga1" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed>
    </object>
    
    Code (markup):
    Any ideas?
     
    okgaz, Jun 28, 2007 IP
  4. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #4
    Use
    
    <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
    
    Code (markup):
     
    it career, Jun 28, 2007 IP
    okgaz likes this.
  5. okgaz

    okgaz Well-Known Member

    Messages:
    450
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    128
    #5
    Thanks, I'll have a look in to that tonight. Does it prevent the page from caching or prevent the browser from using a cached version of the page?

    + REP left for both of the responses so far :)

    Thinking about it it would actually be preffereable if the swf could be cached since some of them will be 2mb+, I just need the stupid swf to remember to include the variable after the question mark :( Does anybody have any more ideas?
     
    okgaz, Jun 28, 2007 IP
  6. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #6
    yup, all you have to do is load it with a random querystring

    or have a static flash, that just laods another flash and the static "preloader" just builds a random integer and applies it to loading the other one.

    embed preloader.swf
    preloader.swf loads "yourmovie.swf?randint=" + randomNumber
     
    ccoonen, Jun 28, 2007 IP
    okgaz likes this.
  7. okgaz

    okgaz Well-Known Member

    Messages:
    450
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    128
    #7
    @ccoonen

    So why does

    <embed src="http://www.sitename.com/swf/demo.swf?gazcode=1aa1ba" ></embed>
    Code (markup):
    appear the same as

    <embed src="http://www.sitename.com/swf/demo.swf" ></embed>
    Code (markup):
    until I press refresh? :confused:
     
    okgaz, Jun 28, 2007 IP
  8. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #8
    Well, web-browsers generally will try to cache anything it loads "INCLUDING" flash .swf files. If you hit your demo.swf in a webbrowser, then change it and hit refresh in teh browser, you will see it might be the same (no change applied). Then do a hard refesh and the change will be reflected. By adding a random querystring it tricks the web-browser into thinking it is a totally different file its loading.
     
    ccoonen, Jul 6, 2007 IP
  9. Gangsta

    Gangsta Active Member

    Messages:
    145
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #9
    first of all adding random number have to help
    also you may use this headers
    header('Content-type: application/x-shockwave-flash');
    header("Expires: Thu, 01 Jan 1970 00:00:00 GMT, -1 ");
    header("Cache-Control: no-cache, no-store, must-revalidate");
    header("Pragma: no-cache");
    Code (markup):
    also read this
    http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14743&sliceId=1
     
    Gangsta, Jul 7, 2007 IP