Is it possible to pass through an image file from a remote URL, without downloading it to the local server?

I have a PHP script that tracks stats and then outputs an image via readfile(). Example:

<img src="http://example.com/image.php?img=1234">

I'd like to use a CDN to reduce load, and take advantage of geo-location services to serve images faster. So, the script needs to output the image straight from the CDN and not download it to the local server for output.

Any advice on how to achieve this? Is it possible? Thanks in advance!

Accepted Answer

Do your tracking, but send the browser to the real location afterwards.

See: http://php.net/manual/en/function.header.php

<?php
header("HTTP/1.0 303 See Other");
header("Location: %the real uri%");
Written by Yoshi
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki