<p>If I load the nextimg URL manually in the browser, it gives a new picture every time I reload. But this bit of code shows the same image every iteration of <code>draw()</code>.</p>

<p>How can I force myimg not to be cached?</p>

<pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;script type="text/javascript"&gt;
      function draw(){
        var canvas = document.getElementById('canv');
        var ctx = canvas.getContext('2d');
        var rx;
        var ry;
        var i;

        myimg = new Image();
        myimg.src = 'http://ohm:8080/cgi-bin/nextimg'

        rx=Math.floor(Math.random()*100)*10
        ry=Math.floor(Math.random()*100)*10
        ctx.drawImage(myimg,rx,ry);
        window.setTimeout('draw()',0);
      }
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="draw();"&gt;
    &lt;canvas id="canv" width="1024" height="1024"&gt;&lt;/canvas&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

The easiest way is to sling an ever-changing querystring onto the end:
```
```
var url = 'http://.../?' + escape(new Date())
```
```
Some people prefer using
```
Math.random()
```
for that instead of
```
escape(new Date())
```
. But the correct way is probably to alter the headers the web server sends to disallow caching.