wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes no cache for images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "no cache for images" Watch "no cache for images" New topic
Author

no cache for images

Cathy Cruise
Greenhorn

Joined: Jun 13, 2004
Posts: 25
is there any code that helps no cache on images?

thanks
cathy
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You can use the nocache meta tag and see if that helps....

Eric
Cathy Cruise
Greenhorn

Joined: Jun 13, 2004
Posts: 25
Here are all my META Tags,

<META HTTP-EQUIV="Cache-Control", CONTENT="no-store, no-cache, must-revalidate">
<META HTTP-EQUIV="Cache-Control", CONTENT="no-Cache">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

yet i still see images are cached. Pages are not though.

Cathy
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
what you could try to do, is to add some uniq id after the image url, here is an example:
<img src="myimg.jpg?12345">

I would prefer to implement this with serverside language,but here is exampleusing javascript:
<script>
//function definition
function writeImage(imgHref,title)
{
var d = new Date();
document.writeln('<img src=\"' + imgHref + '?' + d.getTime() + '\" title=\"' + title + '\" border=0>');
}
</script>
<!-- this is how you put an image -->
<SCRIPT>writeImage('myimage.gif','test');</SCRIPT>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60799
    
  65

If you really really want to do this "right", the url for your img tag should be a servlet which can set the caching headers as approriate and stream the image data as the response. That's really the only viable way you can control (to the extent that the browser pays attention to the headers) caching on static resources.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: no cache for images
 
Similar Threads
How can I prevent to store image in browser cache
PA #1.....picture association
WA #1.....word association
Image Loading Issue in JSP
pragma caching impact on images