What are the best practices for preventing browser caching of external images in PHP?

Browser caching of external images can be prevented by adding cache-control headers to the response sent by the server when fetching the images. This can be achieved by setting the "Cache-Control" header to "no-cache" or by adding a unique query parameter to the image URL to force the browser to always fetch a fresh copy.

<?php
// Prevent browser caching of external images
header("Cache-Control: no-cache");

// Display the image
echo '<img src="https://example.com/image.jpg">';
?>