I'm making an application where the front-end can display resources both as themselves or within a modal. Of course, when the server gets a request for a resource in HTML, it's going to include a layout (with a
<head>, maybe a header and footer in body, and so on). However, if I want a modal with the resource information, I do not need that layout.
How should I ask the server to serve me its resource with or without a resource?
I doubt anything is already present in standardized headers, but is there prior art on standardizing that kind of behavior?
After some thought, I posit that information about that request should go in headers. Here's where I thought it should not go:
Query string: It could have gone as a parameter in the query string, but the preference for a layout does not change the resource I'm asking for, only its "format". For example, imagine an anchor link to my resource, and the front-end decides this should open a modal, except on a middle-click. The URL should stay the same.
Accept/Content-type: The content I'm trying to get is HTML (in one instance), and whether or not I have a layout does not mean I suddenly don't obey to its rules.
X-Requested-With header: Of course, anytime I request the content of a modal in XHR, I should not get a layout, but what if I have a script on my page that fetches a new page dynamically to have it replaced? Moreover, the XHR header would implicitly carry the meaning of not serving the layout without the client/request having any say.
I'm mostly looking for either prior art towards solving that problem, or early proposals about how that could look like, following in the path of the HTTP spec.