At work we are in the process of putting one our blog news sites on a CDN. The CDN would like cached pages to work with their servers. The writers want their news posts up as soon as they publish them. To strike a balance between cached pages to play nice with the CDN and serving up time sensitive posts the decision was made to allow the pages to cache for 30 seconds. This lands outside of my previous flowchart and requires a fresh look at controlling a page’s header information.
Here is the PHP which, as with all headers, need to be placed before any output to the screen.
$expires = 30; //SECONDS header("Pragma: public"); header("Cache-Control: maxage=".$expires); header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');