Jump to content


Photo

Browser cache


  • Please log in to reply
2 replies to this topic

#1 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 19 August 2006 - 02:17 PM

I've got this code at the start of each page:
header('Cache-Control: no-cache');
  header('Pragma: no-cache');
Users upload their profile pic and it is stored on the server always as profile.jpg in their own folder. Its viewing perfectly fine but when they upload a new one the previous image is shown as its cached - how can I tell the browser to reload the image without using a different filename for the image? I've even tried placing a full URL to the image including http:// to no avail and I've spent ages searching on Google for a solution also to no avail.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 19 August 2006 - 02:23 PM

create a random number, then 'call' the image thus:

<img src="path/to/profile.jpg?random" width ... height ... alt....>

Browsers 'think' that's a different image from the one in their cache
Legend has it that reading the manual never killed anyone.
My site

#3 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 19 August 2006 - 02:42 PM

Top job, works a treat!

Many thanks :D
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users