jthsu
asked on
How do I avoid caching a image?
Hi,
I would like to put a banner in my page but I don't want it to be cached(by neither proxy nor browser).
How can I do that by "pure" HTML or Javascript?
I don't have a lot of control, although I know an easy way to solve that is to use Server-sided scripts or HTTP headers.
I would like to put a banner in my page but I don't want it to be cached(by neither proxy nor browser).
How can I do that by "pure" HTML or Javascript?
I don't have a lot of control, although I know an easy way to solve that is to use Server-sided scripts or HTTP headers.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, and even simpler is:
<script languaje="javascript">
<!-- //
document.writeln("<img name='myimage.gif?nocache= " + Math.random() + "' width='200' height='200'>" );
// -->
</script>
... that way you don't have to mess with a Date.
<script languaje="javascript">
<!-- //
document.writeln("<img name='myimage.gif?nocache=
// -->
</script>
... that way you don't have to mess with a Date.
... and as xabi noted, its "language" ;)
ASKER
I put the following code in my HTML but i did not work...
<a href="http://media.exchange-it.com/click.go?b116995=1" target="_top">
<script language="javascript">
<!--
var now = new Date()
document.write("<img name='http://media.exchange-it.com/image.go?b116995=1?nocache=" + escape(now) + "' width='468' height='60'>"
//-->
</script></a>
I wonder if it's because of double question marks it has within the document.write.
<a href="http://media.exchange-it.com/click.go?b116995=1" target="_top">
<script language="javascript">
<!--
var now = new Date()
document.write("<img name='http://media.exchange-it.com/image.go?b116995=1?nocache=" + escape(now) + "' width='468' height='60'>"
//-->
</script></a>
I wonder if it's because of double question marks it has within the document.write.
Try this:
document.write("<img src='http://media.exchange-it.com/image.go?b116995=1?nocache=" + escape(now) + "' width='468' height='60'>" );
document.write("<img src='http://media.exchange-it.com/image.go?b116995=1?nocache=" + escape(now) + "' width='468' height='60'>" );
__________________________ __________ __________ __________ __________ __________ __________ __________ __________ __________ ____
... I think the main things were:
1) missing parentheses at the end, and
2) you had "name" instead of "src"
1) missing parentheses at the end, and
2) you had "name" instead of "src"
... points should go to xabi, ofcourse
ASKER
Hi,
Now I can see the picture. But I still can't avoid the banner being cached.
Any other suggestion?
.....
<a href="http://media.exchange-it.com/click.go?b116995=1" target="_top">
<script language="javascript">
<!--
var now = new Date()
document.write("<img src='http://media.exchange-it.com/image.go?b116995=1?nocache=" + escape(now) + "' width='468' height='60'>");
//-->
</script></a>
Now I can see the picture. But I still can't avoid the banner being cached.
Any other suggestion?
.....
<a href="http://media.exchange-it.com/click.go?b116995=1" target="_top">
<script language="javascript">
<!--
var now = new Date()
document.write("<img src='http://media.exchange-it.com/image.go?b116995=1?nocache=" + escape(now) + "' width='468' height='60'>");
//-->
</script></a>
Ah, I think I see the problem.
Try this:
<a href="http://media.exchange-it.com/click.go?b116995=1" target="_top">
<script language="javascript">
<!--
document.write("<img src='http://media.exchange-it.com/image.go?b116995=1&nocache=" + Math.random() + "' width='468' height='60'>");
//-->
</script></a>
Try this:
<a href="http://media.exchange-it.com/click.go?b116995=1" target="_top">
<script language="javascript">
<!--
document.write("<img src='http://media.exchange-it.com/image.go?b116995=1&nocache=" + Math.random() + "' width='468' height='60'>");
//-->
</script></a>
... the problem being the "?" before "nocache" -- it should have been a "&".
xabi