Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Prevent dynamically generated image caching in Firefox?  RSS feed

 
Christian Olsson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm dynamically generating images (using JFreeChart), for inclusion in HTML pages, as well as in PDFs.

In the HTML pages, I would like the image *not* to be cached, i.e. each image request results in a new image generated.

I'm able to get this to work fine in IE, by setting the image response headers like so:

response.setHeader("Cache-Control","no-cache, no-store,must-revalidate, max-age=-1");

response.setHeader("Pragma","no-cache, no-store"); response.setDateHeader ("Expires", -1);

But Mozilla Firefox (have tried both 1.0 and 1.0.1) still caches the image. Any idea how to prevent this?

Cheers,

/ Christian
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One hack that I use for irritating problems like this is to append a unique string (like a timestamp) to the url.



Opera also has options to fine tune what gets cached, including the option to cache images on pages that otherwise, don't get cached.
 
Christian Olsson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, thanks! What a simple solution, can't believe I didn't think of that..
 
Thomas Whitmore
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I had some problems with FireFox still caching content (pages not images) after I had set the cache header.

I think the answer was, that it was already in the cache and just refreshing wouldn't update the headers which said the cached data was still good. Try Ctrl-R for Reload and/ or clearing FireFox's cache and it should then pick up the no-cache headers after that.

Let me know if this helps.


Cheers,
Thomas
www.powermapjdo.com
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!