Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 54273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:11:39+00:00 2026-05-10T17:11:39+00:00

If I load the nextimg URL manually in the browser, it gives a new

  • 0

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 draw().

How can I force myimg not to be cached?

<html>   <head>     <script type='text/javascript'>       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);       }     </script>   </head>   <body onload='draw();'>     <canvas id='canv' width='1024' height='1024'></canvas>   </body> </html> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:11:40+00:00Added an answer on May 10, 2026 at 5:11 pm

    That actually sounds like a bug in the browser — you could file at http://bugs.webkit.org if it’s in Safari or https://bugzilla.mozilla.org/ for Firefox. Why do i say potential browser bug? Because the browser realises it should not be caching on reload, yet it does give you a cached copy of the image when you request it programmatically.

    That said are you sure you’re actually drawing anything? the Canvas.drawImage API will not wait for an image to load, and is spec’d to not draw if the image has not completely loaded when you try to use it.

    A better practice is something like:

        var myimg = new Image();     myimg.onload = function() {         var rx=Math.floor(Math.random()*100)*10         var ry=Math.floor(Math.random()*100)*10         ctx.drawImage(myimg,rx,ry);         window.setTimeout(draw,0);     }     myimg.src = 'http://ohm:8080/cgi-bin/nextimg' 

    (You can also just pass draw as an argument to setTimeout rather than using a string, which will save reparsing and compiling the same string over and over again.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 76k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer What you're describing is an Entity-Attribute-Value database, which is often… May 11, 2026 at 3:15 pm
  • added an answer SQL Server does not run on Linux. MySQL, however, would… May 11, 2026 at 3:15 pm
  • added an answer I found the solution. Probably has to do with OSX… May 11, 2026 at 3:15 pm

Related Questions

I have a question to the submit- button behavior of internet explorer. If I
If I type in Description: Apple Quantity: 10 Wholesale Cost: 30 Retail Cost: 20
I'm just beginning the process of exploring i18n in CakePHP and I can't seem
I want to use the FTP task in ant, and I have found the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.