title: How do I clear the cache of an iFrame?
body: <p>I have a web page in which I am trying to refresh a iFrame.  I'm trying to do it with something like a <code>&lt;input /&gt;</code> button and javascript.  I can't seem to get the iFrame to reload without clearing the cache.  Getting PHP to clear the cache would be even better.</p>
  
  <p>EDIT-UPDATE</p>
  
  <p>Here's the working implementation inline.</p>
  
  <pre><code>    &lt;input type="button"  onClick="javascript: var iFrame = document.getElementById('compilePreview'); iFrame.src = '&lt;? echo ($myFile); ?&gt;?random=' + (new Date()).getTime() + Math.floor(Math.random() * 1000000);" value="Reload Preview" /&gt;
      &lt;iframe id="compilePreview" src="&lt;? echo ($myFile); ?&gt;" width="940"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>And of coarse the onload was soon to follow, eliminating the need for the button.</p>
  
  <pre><code>    &lt;script&gt;
      window.onload=refreshIframe;
      function refreshIframe(){
      var iFrame = document.getElementById('compilePreview');
      iFrame.src = '&lt;? echo ($myFile); ?&gt;?random=' + (new Date()).getTime() + Math.floor(Math.random() * 1000000);
      }
      &lt;/script&gt;
  </code></pre>