• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

HTML problem

  • Thread starter Thread starter CanITakeYourOrder
  • Start date Start date
C

CanITakeYourOrder

Guest
Hi folks. Quick HTML problem that I hope someone can answer.

How can I stop images being cached in a browser?

I'm running a property website that allows photographs to be uploaded by users. New photos can be uploaded to replace existing ones, but the new photos don't appear on the webpage unless the browser is 'refreshed'.

Any ideas?
 
well

well

I know two methods off the top of my head but I dont support spammers.

:-)

btw I charge a £50 handling fee for each item of uce.
 
Invoice in the post...

Invoice in the post...

As far as I recall, you are using Asp pages, so add this to the top of each page (or slap it in an include file):

Response.expires = 0
Response.ExpiresAbsolute = Now()-2
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl="no-cache"
 
Re: Invoice in the post...

Re: Invoice in the post...

Actually Mark,

My spam idea is working better than my door-to-door leafletting at the moment.

I've been a bit naughty and have started nicking email addresses from other property websites :D

Cheers EddieC for the advice. I had the response.expires, but not the other stuff. So many thanks for that!
 
> How can I stop images being cached in a browser?

and why the hell would you want 90% of bytesize that is static not cached? Thats very mean thing to do both for users who will suffer and for yourself who will pay extra for bandwidth. I can understand if you want to do for special case of upload/preview image only, but not for the whole site. If you are so hell-bent on caching for new images, then just create new filename for newly uploaded images, which could be a hash function of original filename + timestamp.
 
The website is for selling property online.

The problem I had was that people were changing their property photos but this was not being reflected in the 'property search' function.

As the photos are thumbnails, I can't see visitors too my site taking too much of a preformance hit.
 
You can't control image caching via asp you need to setup the caching restrictions in IIS directly.

launch the Internet Services Manager, navigate to the images directory in question, then right-click the folder, and choose Properties.
In the Properties dialog box, select HTTPHeaders, and then click Add. Enter the following three headers:

cache-control:no-cache
pragma:no-cache
expires:0

Its a lot easier in .Net mind
 
Problem is my webhost doesnt allow me to change IIS settings.

The first example by EddieC does seem to work though.

Thanks for everyones help on this one :smokin
 

Advertisers

Back
Top