Header

On this page:

Syntax

<txp:header />

The header tag is a single tag that is used to set HTTP headers.

Note: Usage of this tag assumes you have a good working knowledge of HTTP headers. Headers may break your site if incorrectly configured.

Attributes

Tag will accept the following attributes (case-sensitive):

name="string"
Header name/type.
Default: Content-Type.
replace="boolean"
Whether the existing HTTP header must be replaced entirely, or added to.
Values: 0 (no) or 1 (yes).
Default: 1.
value="string"
Header value.
Default: text/html; charset=utf-8.

Examples

Example 1: Do not cache dynamic articles

If you don’t want an article to be cached by the browser, then the corresponding ‘article’ type form template could contain:

<txp:header name="Cache-Control" value="no-cache, no-store, must-revalidate" />

Example 2: Output articles in JSON format

If you need to output the articles from a section as a JSON document, the corresponding page template could be:

<txp:header value="application/json; charset=utf-8" />
[<txp:article break=",">
{
  "title": "<txp:title escape="json" />",
  "body": "<txp:body escape="json" />"
}
</txp:article>]

The served page will be interpreted by browsers as a JSON application.

Other tags used: article, title.

Genealogy

Version 4.7.0

Tag support added.

See something wrong in this document? Outdated info, a broken link, faulty code example, or whatever? Please write an issue and we’ll fix it.