header
The header function allows you to set an HTTP header for the response.
{% do header('Pragma', 'cache') %}
An example could be to set caching information.
{# Tell the browser to cache something for 30 days #}
{% set expiry = now|date_modify('+30 days') %}
{% do header('Cache-Control','max-age=' ~ (expiry.timestamp - now.timestamp)) %}
{% do header('Pragma', 'cache') %}
{% do header('Expires', expiry|date('D, d M Y H:i:s', 'GMT') ~ ' GMT') %}
Arguments
The header function has the following signature.
header(http_header_name, http_header_value)
Argument | Description |
---|---|
http_header_name | Required The name of the header to set. |
http_header_value | Required The value of the header to set. |