Origin-Agent-Cluster
Enabled Instructs the browser to prevent synchronous scripting access between same-site cross-origin pages.
Origin-Agent-Cluster is a new HTTP response header that instructs the browser to prevent synchronous scripting access between same-site cross-origin pages. Browsers may also use Origin-Agent-Cluster as a hint that your origin should get its own, separate resources, such as a dedicated process.
Usage
This header is enabled by default but you can change its behavior like following.
export default defineNuxtConfig({ // Global security: { headers: { originAgentCluster: <OPTIONS>, }, }, // Per route routeRules: { '/custom-route': { security: { headers: { originAgentCluster: <OPTIONS>, }, }, } }})
You can also disable this header by originAgentCluster: false
.
Default value
By default, Nuxt Security will set following value for this header.
Origin-Agent-Cluster: ?1
Available values
The originAgentCluster
header can be configured with following values.
originAgentCluster: '?1' | false,
What origin-keyed pages cannot do
When your page is in an origin-keyed agent cluster, you give up some abilities to talk to same-site cross-origin pages that were previously available. In particular:
- You can no longer set document.domain. This is a legacy feature that normally allows same-site cross-origin pages to synchronously access each other's DOM, but in origin-keyed agent clusters, it is disabled.
- You can no longer send WebAssembly.Module objects to other same-site cross-origin pages via postMessage().
- (Chrome-only) You can no longer send SharedArrayBuffer or WebAssembly.Memory objects to other same-site cross-origin pages.
When to use origin-keyed agent clusters
The origins that most benefit from the Origin-Agent-Cluster header are those that:
- Perform best with their own dedicated resources when possible. Examples include performance-intensive games, video conferencing sites, or multimedia creation apps.
- Contains resource-intensive iframes that are different-origin, but same-site. For example, if https://mail.example.com embeds https://chat.example.com iframes, origin-keying https://mail.example.com/ ensures that the code written by the chat team cannot accidentally interfere with code written by the mail team, and can hint to the browser to give them separate processes to schedule them independently and decrease their performance impact on each other.
- Expect to be embedded on different-origin, same-site pages, but know themselves to be resource-intensive. For example, if https://customerservicewidget.example.com expects to use lots of resources for video chat, and will be embedded on various origins throughout https://*.example.com, the team maintaining that widget could use the Origin-Agent-Cluster header to try to decrease their performance impact on embedders.