faqts : Computers : Programming : Languages : PHP : Common Problems : Caching

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

34 of 59 people (58%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

I can use META tags and header() to prevent page caching but how do I prevent image caching?

Apr 15th, 2001 15:30
Jeff Roberts, John Watzke, unknown unknown, Matthias Zirngibl, Andrew Peckover


I modified this solution from the one in the HTML group so it was easy 
to read in ASP;

<%sNewImgPath=sImgPath & "?ForceRefresh=" & cstr(cdbl(time()))%>
<img SRC='<%=sNewImgPath%>' BORDER="1">

Their version used a php file but the idea is the same.

Since the Query string (ForceRefresh) on the image path changes with 
the clock each time the page is refreshed, the image gets refreshed too 
because the whole URL is now slightly different.

faqts is phun.