I'm using file_get_contents() to load a dynamic image from an external website.
The problem is that the image has been updated on the remote website but my script is still displaying the old image. I assume the server cache the image somewhere but how can i force the server to clear the cache and use the updated image when getting the file with file_get_contents ?
On my local machine, i had to do CTRL+F5 to force refresh on the image.
I also tryed to add no cache header to my script, but it didn't work:
$image = imagecreatefromstring(file_get_contents($path));
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé
header('Content-type: image/png');
imagepng($image);
exit();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…