Search code examples
javascriptswfobject

Why is Firefox not caching swf object?


Iäm using swf object to embed a swf on my web page. Same swf is shown on 5-6 links on my web page but every time it takes same time to load the swf, any idea?

Here is the code

var href = 'http://xyz.com/dialog/demo.swf';
var flashvars = {};
var params = {};
params.wmode = "transparent";
params.allowscriptaccess = "always";
params.swliveconnect = "true";
params.menu = "false";
var attributes = {};
attributes.id = "c2c";
attributes.name = "c2c";
swfobject.embedSWF(href+"?nocache="+siteID+"&phone="+num+"&siteid="+siteID, "infBox", "100", "60", "9.0.0", "http://xyz.com/dialog/expressInstall.swf", flashvars, params, attributes);

Solution

  • In the following line in your code. You are explicitly letting swfobject not to cache your movie.

    swfobject.embedSWF(href+"?nocache="+siteID+"&phone="+num+"&siteid="+siteID, "infBox", "100", "60", "9.0.0", "http://xyz.com/dialog/expressInstall.swf", flashvars, params, attributes);
    

    You need to remove or update the nocache variable. In your code is not specified but I'm sure that the var "num" is being randomized somewhere in your code.

    suggestion 1 - remove no cache completely:

    swfobject.embedSWF(href, "infBox", "100", "60", "9.0.0", "http://xyz.com/dialog/expressInstall.swf", flashvars, params, attributes);
    

    solution 2 - only remove the num variable from the swf address query

    swfobject.embedSWF(href+"?nocache="+siteID+"&phone="+"&siteid="+siteID, "infBox", "100", "60", "9.0.0", "http://xyz.com/dialog/expressInstall.swf", flashvars, params, attributes);