Get a Demo
Table of contents

header

The header function allows you to set an HTTP header for the response. 

This function is unique to Aptuitiv. It is not part of the core Twig functionality.
{% 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 Link

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.
Get Started With Aptuitiv