Use GD – 2a: Not Modified
When creating an image with PHP per call, why should the server have to create the image every time. In part two of using GD I’ll show how to use the 304 Not Modified header, and storing the image as cache.
To start we need to pass more info about the image from the previous post. Need to pass the last modified date and time, tell the browser that it can cache it and for how long, when the image would expire and an ID for the file.
41 42 43 44 45 | header("Last-Modified: ".gmdate("D, d M Y H:i:s", filemtime($sFile))." GMT"); header("Pragma: public"); header("Cache-Control: maxage=".(60*60*24*2)); header("Expires: ".gmdate("D, d M Y H:i:s", strtotime("+2 days"))." GMT"); header("ETag: ".md5($sFile)); |

