Habari\Session::cache_limiter PHP Method

cache_limiter() public static method

Sends HTTP headers that limit the cacheability of the page.
public static cache_limiter ( string $type = 'nocache' ) : void
$type string The type of caching headers to send. One of: 'public', 'private_no_expire', 'private', 'nocache', or ''.
return void
    public static function cache_limiter($type = 'nocache')
    {
        $expires = DateTime::create('+' . session_cache_expire() . ' seconds')->format(DateTime::RFC1123);
        $last_modified = DateTime::create()->format(DateTime::RFC1123);
        switch ($type) {
            case 'public':
                header('Expires: ' . $expires, true);
                header('Cache-Control: public, max-age=' . $expires, true);
                header('Last-Modified: ' . $last_modified, true);
                break;
            case 'private_no_expire':
                header('Cache-Control: private, max-age=' . $expires . ', pre-check=' . $expires, true);
                header('Last-Modified: ' . $last_modified, true);
                break;
            case 'private':
                header('Expires: Thu, 19 Nov 1981 08:52:00 GMT', true);
                header('Cache-Control: private max-age=' . $expires . ', pre-check=' . $expires, true);
                header('Last-Modified: ' . $last_modified, true);
                break;
            case 'nocache':
                header('Expires: Thu, 19 Nov 1981 08:52:00 GMT', true);
                header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true);
                header('Pragma: no-cache', true);
                break;
            case '':
                return;
                break;
        }
    }