Transient Elements
The transient attribute marks an element as session-scoped. The element's content in the document serves as the default for new sessions. Each session sees its own version, and changes do not affect other sessions or the canonical document.
Attribute form
<ul id="cart" p:transient>
<li>Default item</li>
</ul>
p:transient takes no value. It can be applied to any element within a Pagelove namespace.
Reading transient elements
When a document containing transient elements is requested:
- If the session has stored content for the element, that content is served.
- If not, the document default is served unchanged.
Transient resolution is per‑session and per‑request — it is never cached across sessions. Every response built from a document that carries a transient marker is served Cache-Control: private: the full document and any selector‑range read of it (whichever element the selector matches), with or without a session. Shared caches therefore never store one visitor's transient content and replay it to another.
Transient element content is not visible to Resource Binding. Bindings query the canonical document, not session‑scoped content. To use transient data elsewhere, the client must read it from the DOM and transfer it explicitly.
Mutating transient elements
PUT and POST
A PUT or POST targeting a transient element (or any child of one) writes to the session rather than the document.
PUT /page.html #cart
The new content must preserve the element's identity — it must still match the CSS selector that identifies it. If it does not, the request is rejected:
422 Unprocessable Entity
For example, given <ul id="cart" p:transient>:
<div id="cart">…</div>is permitted — the#cartselector still matches.<ul id="different">…</ul>is rejected — the#cartselector no longer matches.
The transient attribute does not need to be included in the request body; it is preserved automatically.
DELETE
A DELETE targeting a transient element removes the session content, reverting to the document default on the next request.
DELETE /page.html #cart
Child mutations
When a mutation targets a child of a transient element, it is treated as a mutation of the transient ancestor.
<ul id="cart" p:transient>
<li id="item1">Apples</li>
</ul>
A PUT to #item1 is handled as a transient mutation of #cart, because #cart is the transient ancestor.
Default behaviour
When no session content exists for a transient element, the directive is inert — the document default is served. This applies to:
- New sessions
- Sessions that have not yet modified the element
- Sessions where the transient content has expired
Transient content expires 30 days after it was written, regardless of the session's own configured lifetime — the two are independent.
Sessions and access control
Every visitor has a session, including unauthenticated users: the edge proxy establishes a pagelove_session cookie automatically on the first request and replays it thereafter. This means unauthenticated users can modify transient elements unless access control rules prevent it.
Use AuthorizationRule declarations to control who may read or write transient elements, just as with any other Pagelove content.
Error responses
| Status | Condition |
|---|---|
| 409 Conflict | A mutation reached the server with no session established. On the public web the edge proxy always establishes the pagelove_session cookie first, so this is not normally reachable. |
| 405 Method Not Allowed | Unsupported HTTP method for a transient element. |
| 422 Unprocessable Entity | PUT content does not match the element's CSS selector. |
Future extensibility
The attribute value is reserved for a per‑element TTL in seconds:
<ul id="cart" p:transient="3600">
<li>Expires in 1 hour</li>
</ul>
Currently, this value is ignored: every transient write uses a fixed 30-day TTL regardless of what's specified here. Per‑element TTL support is planned for a future release.
Example: default content for a new session
Store a page with a transient element containing default content:
<!DOCTYPE html>
<html xmlns:p="https://pagelove.org/1.0">
<body>
<ul id="cart" p:transient>
<li>Default item</li>
</ul>
</body>
</html>
A fresh session receives the document default:
GET /sspi-transient-page.html
HTTP/1.1 200
<!DOCTYPE html>
<html>
<body>
<ul id="cart">
<li>Default item</li>
</ul>
</body>
</html>
Summary
p:transient provides session‑scoped element content within Pagelove's declarative document model.
It:
- Serves the document default for new sessions
- Replaces element content per‑session on every request
- Routes mutations (PUT/POST/DELETE) to the session rather than the document
- Validates that PUT content preserves the element's selector identity
- Preserves the
transientattribute automatically - Uses the standard authorization rule system for access control
See also
- PUT method — replace element content
- DELETE method — remove elements