Lets an open page ask whether its server-rendered HTML is still current.
A change to a template or content file may affect any page, or none. Rather
than reloading every open page, Volt's dev client revalidates the page it is
on: it requests the page again with the entity tag of the HTML it was served
and reloads only when the server answers with something other than
304 Not Modified.
Volt.DevServer does this for every successful HTML response that passes
through it, whether it adds the dev client or the page already loads it with
<script type="module" src="/@volt/client.js">. A server that sends HTML
without going through Volt.DevServer takes part by:
- computing
etag/1of the rendered HTML; - answering
304with an empty body whenfresh?/2is true; - otherwise sending the tag in the
etagresponse header and in thedata-volt-etagattribute of the client<script>.
Pages without the attribute reload on every document update.
Summary
Functions
The attribute of the client <script> that holds the page's entity tag.
Compute the entity tag of rendered HTML.
Return whether the request already holds the HTML that etag identifies.
The attribute of the client <script> that lets the client patch the page in
place instead of reloading it. Its value is a selector for elements that
client code owns, or empty.
Functions
@spec attribute() :: String.t()
The attribute of the client <script> that holds the page's entity tag.
Compute the entity tag of rendered HTML.
@spec fresh?(Plug.Conn.t(), String.t()) :: boolean()
Return whether the request already holds the HTML that etag identifies.
@spec morph_attribute() :: String.t()
The attribute of the client <script> that lets the client patch the page in
place instead of reloading it. Its value is a selector for elements that
client code owns, or empty.