HTTP Headers
Device Memory
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The HTTP Device-Memory request header is used in device client hints to indicate the approximate amount of available RAM on the client device, in gigabytes.
The header is part of the Device Memory API.
Client hints are accessible only on secure origins.
A server has to opt in to receive the Device-Memory
header from the client, by first sending the Accept-CH response header.
Servers that opt in to the Device-Memory
client hint will typically also specify it in the Vary header to inform caches that the server may send different responses based on the header value in a request.
Syntax
Device-Memory: <number>
Directives
The approximate amount of device RAM. Possible values are: 0.25, 0.5, 1, 2, 4, 8.
The amount of device RAM can be used as a fingerprinting variable, so values for the header are intentionally coarse to reduce the potential for its misuse.
Example
The server must first opt in to receive the Device-Memory
header by including Accept-CH
in its response headers with Device-Memory
as the value:
Example:
When the client makes subsequent requests, it can include the Device-Memory
header with its information, such as:
Example:
Device-Memory: 1
How to Modify Header using Requestly
Requestly is a handy tool that helps you change the Device Memory header in your browser’s network requests. This can be useful for testing how your website performs or adapts based on different device memory configurations. Steps to Modify the Device Memory Header:
- Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
- Create a new rule: Click on “Create Rule” and choose “Modify Headers“ from the list of available rule types.
- Add a new header modification:
- Under “Action”, select “Add” or “Override”.
- In the “Header Name” field, enter Device-Memory.
- In the “Header Value” field, enter the desired memory value in gigabytes (e.g., 4).
- Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-website.com/*).
- Save the rule.
By modifying the Device Memory header, you can simulate different device capabilities to see how your website behaves on devices with varying memory sizes. This helps improve performance and user experience across a range of devices.
Table of Contents
- No headings found.