CI_Output::set_cache_header PHP Method

set_cache_header() public method

Set the HTTP headers to match the server-side file cache settings in order to reduce bandwidth.
public set_cache_header ( integer $last_modified, integer $expiration ) : void
$last_modified integer Timestamp of when the page was last modified
$expiration integer Timestamp of when should the requested page expire from cache
return void
    public function set_cache_header($last_modified, $expiration)
    {
        $max_age = $expiration - $_SERVER['REQUEST_TIME'];
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $last_modified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
            $this->set_status_header(304);
            exit;
        } else {
            header('Pragma: public');
            header('Cache-Control: max-age=' . $max_age . ', public');
            header('Expires: ' . gmdate('D, d M Y H:i:s', $expiration) . ' GMT');
            header('Last-modified: ' . gmdate('D, d M Y H:i:s', $last_modified) . ' GMT');
        }
    }