Edit this page

up.protocol X-Up-Target
HTTP header

This request header contains the CSS selector targeted for a successful fragment update.

Server-side code is free to optimize its response by only rendering HTML that matches the selector. For example, you might prefer to not render an expensive sidebar if the sidebar is not targeted.

Unpoly will usually update a different selector in case the request fails. This selector is sent as a second header, X-Up-Fail-Target.

The user may choose to not send this header by configuring up.network.config.requestMetaKeys.

Example

X-Up-Target: .menu
X-Up-Fail-Target: body

Changing the render target from the server

The server may change the render target context by including a CSS selector as an X-Up-Target header in its response.

Content-Type: text/html
X-Up-Target: .selector-from-server

<div class="selector-from-server">
  ...
</div>

The frontend will use the server-provided target for both successful (HTTP status 200 OK) and failed (status 4xx or 5xx) responses.

The server may also set a target of :none to have the frontend render nothing. In this case no response body is required:

Content-Type: text/html
X-Up-Target: :none
This website uses cookies to improve usability and analyze traffic.
I accept or learn more