title: How to force a web browser NOT to cache images
body: <h2>Background</h2>
  
  <p>I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator to upload an image related to the event. On the HTML page displaying the form, I am also showing a preview of the picture uploaded (HTML img tag).</p>
  
  <h2>The Problem</h2>
  
  <p>The problem happens when the administrator wants to change the picture. He would just have to hit the "browse" button, pick a new picture and press ok. And this works fine.</p>
  
  <p>Once the image is uploaded, my back-end CGI handles the upload and reloads the form properly.</p>
  
  <p>The problem is that the image shown <strong>does not</strong> get refreshed. The old image is still shown, even though the database holds the right image. I have narrowed it down to the fact that the IMAGE IS CACHED in the web browser. If the administrator hits the RELOAD button in Firefox/Explorer/Safari, everything gets refreshed fine and the new image just appears.</p>
  
  <h2>My Solution - Not Working</h2>
  
  <p>I am trying to control the cache by writing a HTTP Expires instruction with a date very far in the past.</p>
  
  <pre><code>Expires: Mon, 15 Sep 2003 1:00:00 GMT
  </code></pre>
  
  <p>Remember that I am on the administrative side and I don't really care if the pages takes a little longer to load because they are always expired.</p>
  
  <p>But, this does not work either.</p>
  
  <h2>Notes</h2>
  
  <p>When uploading an image, its filename is not kept in the database. It is renamed as <strong>Image.jpg</strong> (to simply things out when using it). When replacing the existing image with a new one, the name doesn't change either. Just the content of the image file changes.</p>
  
  <p>The webserver is provided by the hosting service/ISP. It uses Apache.</p>
  
  <h2>Question</h2>
  
  <p>Is there a way to force the web browser to NOT cache things from this page, not even images?</p>
  
  <p>I am juggling with the option to actually "save the filename" with the database. This way, if the image is changed, the src of the IMG tag will also change. However, this requires a lot of changes throughout the site and I rather not do it if I have a better solution. Also, this will still not work if the new image uploaded has the same name (say the image is photoshopped a bit and re-uploaded).</p>