• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

no cache for images  RSS feed

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any code that helps no cache on images?

thanks
cathy
 
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the nocache meta tag and see if that helps....

Eric
 
Cathy Cruise
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Author and ninkuma
Marshal
Posts: 66826
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!