How to disable browser caching for an image?

D

Dominic

Hi all,

If I want to disable browser caching for the whole page, I can use the
following.

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

However, what I really want is to disable browser caching for a
certain image in the page. Is it possible?

Thanks
Dom
 
M

Mark Parnell

Hi all,
G'day.

If I want to disable browser caching for the whole page, I can use the
following.

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

You can use whatever you like. But that doesn't mean the browser will
not cache it.
However, what I really want is to disable browser caching for a
certain image in the page. Is it possible?

No. You can't control caching at all - you can suggest things such as
the above, but there is no way to guarantee that it won't be cached. And
there is definitely no way to do it for an individual image.
 
M

Mitja

Mark Parnell said:
You can use whatever you like. But that doesn't mean the browser will
not cache it.

Very true. It's a suggestion, not an order for the browser. In practice,
however, it mostly works.

No. You can't control caching at all - you can suggest things such as
the above, but there is no way to guarantee that it won't be cached.
And there is definitely no way to do it for an individual image.

It can be done with .htaccess - look it up on the web. Since there are many
things you can do with an .htaccess, another hint is the <files> tag. You'll
probably want something like
<Files graphics/myveryspecialimage.png>
Header set Expires: 0
</Files>

This requires ftp access to the server, apache running and configured in
such a way that it heeds .htaccess. It may seem like a lot of conditions,
but fortunately that's often how things are set up.
 
W

Whitecrest

If I want to disable browser caching for the whole page, I can use the
following.
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
Sometimes...

However, what I really want is to disable browser caching for a
certain image in the page. Is it possible?

Do you want it to not cache so it is not on their computer? (won't
happen) or because you want to make sure they have the most recent
version of the image every time they go to the page? this can be
accomplished by changing the name of the image, say with the current
time.

Or, use Flash.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top