Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


teamsteve

59 posts

Master Geek
+1 received by user: 1


#31797 31-Mar-2009 09:10
Send private message

I've got one image on this website which is dynamically generated (ie: <img src="my_dynamic_image.asp" />) but it looks like it's caching for some people, so they aren't seeing the newest version of it all the time

Is there a way to set this one file to not be cached?


Thanks!

Create new topic
freitasm
BDFL - Memuneh
80647 posts

Uber Geek
+1 received by user: 41031

Administrator
ID Verified
Trusted
Geekzone
Lifetime subscriber

  #204354 31-Mar-2009 09:19
Send private message

Since this is a dynamic page, couldn't you add something like a GUID to the end of its name as a parameter, such as my_dynamic_image.asp?v=[GUID]...

This way the browser will see each request as a different one, always...




Referral links: Quic Broadband (free setup code: R587125ERQ6VE) | Samsung | AliExpress | Wise | Sharesies 

 

Support Geekzone by subscribing (browse ads-free), or making a one-off or recurring donation through PressPatron.

 




teamsteve

59 posts

Master Geek
+1 received by user: 1


  #204359 31-Mar-2009 09:34
Send private message

freitasm: Since this is a dynamic page, couldn't you add something like a GUID to the end of its name as a parameter, such as my_dynamic_image.asp?v=[GUID]...

This way the browser will see each request as a different one, always...

It's not really an option, the site is using an off the shelf shopping cart which I'm reluctant to change the code of (although I've just found that my customer doesn't seem so restrained in changing my code Yell)

I've just added...

    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="pragma"        content="no-cache" />
    <meta http-equiv="expires"       content="0" />

... to the head of the pages containing the dynamic image which should stop the whole pages from being cached, but if there were a way to localise that to a single file that'd be ace

RedJungle
Phil Gale
1108 posts

Uber Geek
+1 received by user: 46

Trusted
Red Jungle
Subscriber

  #204376 31-Mar-2009 11:16
Send private message

I would use the method Mauricio outlined as it's the most reliable. Add a random guid or timestamp parameter to the image URL.



freitasm
BDFL - Memuneh
80647 posts

Uber Geek
+1 received by user: 41031

Administrator
ID Verified
Trusted
Geekzone
Lifetime subscriber

  #204378 31-Mar-2009 11:17
Send private message

Fair enough although adding a GUID as a parameter to that dynamically generate image would be one additional line and one change to the output - less than your changes I think...




Referral links: Quic Broadband (free setup code: R587125ERQ6VE) | Samsung | AliExpress | Wise | Sharesies 

 

Support Geekzone by subscribing (browse ads-free), or making a one-off or recurring donation through PressPatron.

 


slartibartfast
61 posts

Master Geek


  #204379 31-Mar-2009 11:18
Send private message

If you don't want to change the code, then you could do a slight variant of what Mauricio is proposing.

Assuming you can put a proxy of some sort in front of the website (Squid perhaps?) and also assuming that the URI you're trying to prevent caching on is constant then you could put a rule in to rewrite any occurence of the URI and append to it ?v={timestamp}.

Not as nice as Mauricio's suggestion but might work


freitasm
BDFL - Memuneh
80647 posts

Uber Geek
+1 received by user: 41031

Administrator
ID Verified
Trusted
Geekzone
Lifetime subscriber

  #204380 31-Mar-2009 11:19
Send private message

set TypeLib = Server.CreateObject("Scriptlet.TypeLib")
?version=[% =left(cstr(TypeLib.Guid),38) %]
set Typelib = nothing






Referral links: Quic Broadband (free setup code: R587125ERQ6VE) | Samsung | AliExpress | Wise | Sharesies 

 

Support Geekzone by subscribing (browse ads-free), or making a one-off or recurring donation through PressPatron.

 


 
 
 
 

Shop now for Dyson appliances (affiliate link).

mjb

mjb
996 posts

Ultimate Geek
+1 received by user: 67

Trusted

  #204443 31-Mar-2009 15:39
Send private message

teamsteve: I've just added...

???
???
???

... to the head of the pages containing the dynamic image which should stop the whole pages from being cached, but if there were a way to localise that to a single file that'd be ace


You want to send extra headers before the image in the dynamic image page. not sure how you do it in asp (getting hives here), but in php it's:

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // (Just an old date)





contentsofsignaturemaysettleduringshipping


mjb

mjb
996 posts

Ultimate Geek
+1 received by user: 67

Trusted

  #204444 31-Mar-2009 15:40
Send private message

Oh look.... here it is: http://support.microsoft.com/kb/234067.

So, you want asp code:

<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
%>




contentsofsignaturemaysettleduringshipping


Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.