Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

caching of images

Status
Not open for further replies.

johk02

Programmer
Joined
Aug 20, 2003
Messages
169
Location
AU
Hi,
Is there a way of preventing caching of images by the browser??
I have tried

<head>
<title><title>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
</head>
<body>

</body>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
</head>

Thanks
Jonas
 
<cfheader NAME="Expires" VALUE="Mon, 06 Jan 1990 00:00:01 GMT">
<cfheader NAME="Pragma" VALUE="no-cache">
<cfheader NAME="cache-control" VALUE="no-cache">

That works fine for me, has for almost two years now..

Hope that helps,

Tony

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Hi,
I tried that and it still cached the images, but it didn't cach the .cfm file.
Is it possible to prevent caching of images or is it just for the .htm,.cfm,asp etc files??

I have attached the code below. I decieded to the image slideshow in javascript instead of coldfusion due to that some clients want to have their site put on a CD

Thanks Jonas
#################
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"<html>
<head>
<cfheader NAME="Expires" VALUE="Mon, 06 Jan 1990 00:00:01 GMT">
<cfheader NAME="Pragma" VALUE="no-cache">
<cfheader NAME="cache-control" VALUE="no-cache">

<script language="JavaScript">
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</script>

<script language="JavaScript">
IE4plus = (document.all) ? true : false;
NS4 = (document.layers) ? true : false;

function clickIE()
{
return false;
}

function clickNS(e)
{
if (e.which==2 || e.which==3)
{
return false;
}
}
if (!IE4plus)
{
document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);
document.onmousedown=clickNS;
document.onmouseup= clickNS;
document.oncontextmenu=clickIE; // For NS 6+
}
else
{
document.onmouseup= clickIE;
document.oncontextmenu=clickIE;
}

</script>


<script language="javascript" type="text/javascript">
<!--
// QueryString
// Call function by x = querystring("variable") returns variable=x
function QueryString(key) {
var value = null;
for (var i=0;i<QueryString.keys.length;i++) {
if (QueryString.keys[ i ]==key) {
value = QueryString.values[ i ];
break;
}
}
return value;
}
QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse() {
var query = window.location.search.substring(1);
// Add checking here
var pairs = query.split("&");
for (var i=0;i<pairs.length;i++) {
var pos = pairs[ i ].indexOf('=');
if (pos >= 0) {
var argname = pairs[ i ].substring(0,pos);
var value = pairs[ i ].substring(pos+1);
QueryString.keys[QueryString.keys.length] = argname;
QueryString.values[QueryString.values.length] = value;
}
}
}
QueryString_Parse();

var x;
x = QueryString("var1");


myPix = new Array("bigimages/image1.jpg","bigimages/image2.jpg","bigimages/image3.jpg","bigimages/image4.jpg","bigimages/image5.jpg","bigimages/image6.jpg","bigimages/image7.jpg","bigimages/image8.jpg","bigimages/image9.jpg","bigimages/image10.jpg","bigimages/image11.jpg","bigimages/image12.jpg","bigimages/image13.jpg","bigimages/image14.jpg","bigimages/image15.jpg")
thisPic = 0
imgCt = myPix.length - 1

function processPrevious() {
if (document.images && thisPic > 0) {
thisPic--
document.imagePoster.src=myPix[thisPic]
}
}

function processNext() {
if (document.images && thisPic < imgCt) {
thisPic++
document.imagePoster.src=myPix[thisPic]
}
}
//-->

</script>
<title>Image Slideshow</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="itsa.css" rel="stylesheet" type="text/css">

</head>

<body onLoad="if ('Navigator' == navigator.appName) document.forms[0].reset();" >

<table width="605" height="420" border="0" align="center" class="dashed_border">
<tr>
<td colspan="2"><div align="center" class="Kristoffer">Image Slideshow
</div></td>
</tr>
<tr>
<td height="400" colspan="2">
<script language="javascript" type="text/javascript">
document.write('<img src="'+x+'" name="imagePoster" width="600" height="400">');
</script> </td>
</tr>
<tr>
<td width="50%"><div align="right"><span class="Kristoffer">&lt;&lt; <a href="javascript:processPrevious()" class="Kristoffer"></a></span><a href="javascript:processPrevious()" class="Kristoffer">Previous&nbsp;&nbsp;&nbsp;</a></div></td>
<td width="50%"><a href="javascript:processNext()" class="Kristoffer">&nbsp;&nbsp;&nbsp;Next</a><span class="Kristoffer"> &gt;&gt;</span></td>
</tr>
</table>

</body>

</html>
###################
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top