How to prevent krpano plugin caching?

  • I have my own plugin swf that I have krpano include via the krpano xml file. Before using krpano, I would embed the swf directly into my page and could ensure that the swf was never cached by any clients (and always getting the latest changes) by adding a random number as a query string parameter to the swf url like in this example javascript using swfobject:

    Code
    var randomId = Math.random(10000);
    var so = new SWFObject("my.swf?randomId="+randomId,"mySWFObject","100%","100%","9.0.28","#000000");

    Now using krpano to include my swf, I instead specify my swf url in the krpano xml like this:

    Code
    <plugin 
    		name="mySWFObject" 
    		url="%SWFPATH%/my.swf" 
    		width="100%" 
    		height="100%"
    	/>

    Unless I dynamically generate my krpano xml, I can't specify the random number anymore in the plugin URL. What I am wondering is if there is any built-in way through the krpano xml, to make sure my plugin swf does not get cached? Thanks!

  • Hi,

    there is currently no build-in way,
    but you could set the plugin url from the html file,

    e.g.
    let your xml unchanged and add this in the html:

    Code
    so.addVariable("plugin[mySWFObject].url","%SWFPATH%/my.swf?randomId="+Math.random(10000) );

    or just create/pass a "random" variable, and build the plugin/url dynamically:

    html:

    Code
    so.addVariable("js_randomid", Math.random(10000) );

    xml:

    Code
    <krpano onstart="loadmyplugin();">
    
    
    <action name="loadmyplugin">
      addplugin(mySWFObject);
      set(plugin[mySWFObject].width, 100%);
      set(plugin[mySWFObject].height, 100%);
      txtadd(plugin[mySWFObject].url, 'my.swf?randomId=', get(js_randomid) );
    </action>

    best regards,
    Klaus

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!