Forum Moderators: coopster

Message Too Old, No Replies

Images on another server

         

Pico_Train

2:32 pm on Feb 23, 2010 (gmt 0)

10+ Year Member



Hi there,

I have a site where I call images from another server. The image filenames are stored in my DB and I just add the rest of the path to each image dynamically in my php page.

Now the people providing the images are whining a bit.

Is there anyway, without downloading all the images and then uploading them to my server, everytime I update my DB, to cache those images and not have to call them from their server?

Thanks

jamie

1:40 pm on Feb 26, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



the people on the other server could send some expires headers with a really long expiry (1 year) - that would help. they have to make that change to apache.

i'm not sure i understand completely whether you are able to download them or not, but if you don't mind storing them on your server:

you could change the php script which adds the paths to save the image file in a cache folder on your own site. so each image is called like this <img src="script.php?img=/image/foto.jpg">

script.php checks to see if the img exists in your cache folder, and if not downloads it from the other server and saves to the cache folder. that way you gradually transfer the images over to your own server as they are requested.

if you chose this second option, better still would be to choose a static (but non-existing) folder in the src="" and mod_rewrite that to the script which processes the images. e.g. <img src="/cache/image/foto.jpg"> where the folder cache doesn't exist and you use apache to rewrite that to script.php?img=/image/foto.jpg

coopster

1:56 pm on Feb 26, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



caching in their browser you mean? You could send the appropriate headers ... but since you are calling from a different server that is going to be impossible for you to do. That's assuming that the other server is not already doing so.

where I call images from another server The image filenames are stored in my DB and I just add the rest of the path to each image dynamically in my php page.


Actually, if you are merely building the image path in your PHP script you are not "calling" the images. The end-user's browser is calling the image.