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


#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
79258 posts

Uber Geek

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...




Please support Geekzone by subscribing, or using one of our referral links: Samsung | AliExpress | Wise | Sharesies | Hatch | GoodSyncBackblaze backup




teamsteve

59 posts

Master Geek


  #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

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
79258 posts

Uber Geek

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...




Please support Geekzone by subscribing, or using one of our referral links: Samsung | AliExpress | Wise | Sharesies | Hatch | GoodSyncBackblaze backup


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
79258 posts

Uber Geek

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






Please support Geekzone by subscribing, or using one of our referral links: Samsung | AliExpress | Wise | Sharesies | Hatch | GoodSyncBackblaze backup


mjb

mjb
996 posts

Ultimate Geek

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


 
 
 

Cloud spending continues to surge globally, but most organisations haven’t made the changes necessary to maximise the value and cost-efficiency benefits of their cloud investments. Download the whitepaper From Overspend to Advantage now.

mjb

mjb
996 posts

Ultimate Geek

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





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









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.