Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I avoid caching a image?

Posted on 2000-03-10
12
Medium Priority
?
179 Views
Last Modified: 2010-04-09
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.
0
Comment
Question by:jthsu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 2
  • 2
12 Comments
 
LVL 8

Accepted Solution

by:
xabi earned 400 total points
ID: 2603731
Here goes the code.

------- 8< --------- 8< ------
<script languaje="javascript">
<!--
var now = new Date()
document.write("<img name='foo.gif?nocache=" + escape(now) + "' width='200' height='200'>"
//-->
</script>
------- 8< ---------- 8< -------

replace your <image ....> with my code and modify it to your image size and name.

xabi
0
 
LVL 8

Expert Comment

by:xabi
ID: 2603733
It's language, not languaje ... sorry (Typo)

xabi
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2604779
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Expert Comment

by:knightEknight
ID: 2604783
... and as xabi noted, its "language"  ;)
0
 

Author Comment

by:jthsu
ID: 2605490
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.
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2605538
Try this:

document.write("<img src='http://media.exchange-it.com/image.go?b116995=1?nocache=" + escape(now) + "' width='468' height='60'>" );

0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2605539
________________________________________________________________________________________________________________________
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2605543
... I think the main things were:
1) missing parentheses at the end, and
2) you had "name" instead of "src"
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2605547
... points should go to xabi, ofcourse
0
 

Author Comment

by:jthsu
ID: 2605600
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>
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2605620
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>
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2605625
... the problem being the "?" before "nocache" -- it should have been a "&".
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question