<embed> tag does not reload src file until browser restart.

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
8mile
Forum Newbie
Posts: 2
Joined: Sat Jul 05, 2008 7:32 pm

<embed> tag does not reload src file until browser restart.

Post by 8mile »

Hi all,

I have a PHP application that uses SWF charts to display data in graphical format. The SWF charts that i use is from http://www.maani.us/. The front page of the application has the charts displayed,
and based on a users selection, the charts has to get updated. However, the <src> file(.xml or.php) that the chart uses gets updated based on the user selection, but when the html/php page load, the charts
display the previous data(stale). The only way to make the chart take the new data is to close my IE/mozilla and open a new instance.

Is there anyway I can force a reload in the <embed> tag?? so that on a page reload, the <embed> tag picks the updated <src> ? I am stuck, please help.

Heres what i have

Code: Select all

 
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
   codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" 
   WIDTH="630" 
   HEIGHT="260" 
   id="charts" />
<PARAM NAME="movie" VALUE="charts.swf?library_path=charts_library&xml_source=CCPoverview.xml" />
<PARAM NAME="quality" VALUE="high" />
<PARAM NAME="bgcolor" VALUE="#000000" />
<param name="allowScriptAccess" value="sameDomain" />
 
<EMBED src="charts.swf?library_path=charts_library&xml_source=CCPoverview.xml"
       quality="high" 
       bgcolor="#000000" 
       WIDTH="630" 
       HEIGHT="260" 
       NAME="charts" 
       allowScriptAccess="sameDomain" 
       swLiveConnect="false" 
       TYPE="application/x-shockwave-flash" 
       PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
 
Thanks,
Kris
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: <embed> tag does not reload src file until browser restart.

Post by Eran »

I don't see what part of the data is dynamic. If its static and constant, why shouldn't it load the same data each time?
8mile
Forum Newbie
Posts: 2
Joined: Sat Jul 05, 2008 7:32 pm

Re: <embed> tag does not reload src file until browser restart.

Post by 8mile »

Code: Select all

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
   codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" 
   WIDTH="630" 
   HEIGHT="260" 
   id="charts" />
<PARAM NAME="movie" VALUE="charts.swf?library_path=charts_library&xml_source=[b]CCPoverview.xml[/b]" />
<PARAM NAME="quality" VALUE="high" />
<PARAM NAME="bgcolor" VALUE="#000000" />
<param name="allowScriptAccess" value="sameDomain" />
 
<EMBED src="charts.swf?library_path=charts_library&[b]xml_source=CCPoverview.xml"[/b]
       quality="high" 
       bgcolor="#000000" 
       WIDTH="630" 
       HEIGHT="260" 
       NAME="charts" 
       allowScriptAccess="sameDomain" 
       swLiveConnect="false" 
       TYPE="application/x-shockwave-flash" 
       PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
The source file, in this case "CCPoverview.xml" will change, meaning the contents of that xml file will change based on the user's selection of certain options. After the user selects, the main page reloads, and the charts must be updated with the new data(because the file[CCPoverview.xml] will be updated), however the embedded SWF(charts) does not reload the file, instead I believe it loads it from its cache. The only way this now works his, closing IE/mozilla and reopening, after which it picks up the updated file and displays.

any ideas?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: <embed> tag does not reload src file until browser restart.

Post by Eran »

So the file name stays the same? this is the reason it is cached, since to the browser it seems as if nothing changed. What you need to do is add a random parameter which will force the browser to refetch the data - something like:

Code: Select all

 
charts.swf?library_path=charts_library&xml_source=CCPoverview.xml&rand=<?php echo rand(0,10000000); ?>
 
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: <embed> tag does not reload src file until browser restart.

Post by Ollie Saunders »

Unfortunately this is a really annoying problem because embeds and external files used by embeds don't really listen to the Last-Modified header so changing the name is really the only way round it. I know, it sucks. I had the same problem a few years back and ended up renaming files on the server. Random parameter is a much better idea though.
Post Reply