Save-Data
Save-Data
The Save-Data
network client hint request header field is a boolean which indicates the client's preference for reduced data usage. This could be for reasons such as high transfer costs, slow connection speeds, etc.
Header type | Request header, Client hint |
---|---|
Forbidden header name | no |
CORS-safelisted response header | no |
A value of On
indicates explicit user opt-in into a reduced data usage mode on the client, and when communicated to origins allows them to deliver alternative content to reduce the data downloaded such as smaller image and video resources, different markup and styling, disabled polling and automatic updates, and so on.
Note: Disabling HTTP/2 Server Push (RFC 7540, section 8.2: Server Push) might be desirable too for reducing data downloads.
Note: The Save-Data
network client hint should be used to reduce data set to the client irrespective of the values of other client client hints that indicate network capability, like Downlink
and RTT
.
Syntax
Save-Data: <sd-token>
Directives
- <sd-token>
-
A value indicating whether the client wants to opt in to reduced data usage mode.
on
indicates yes, whileoff
(the default) indicates no.
Examples
The Vary
header ensures that the content is cached properly (for instance ensuring that the user is not served a lower-quality image from the cache when Save-Data
header is no longer present [e.g. after having switched from cellular to Wi-Fi]).
With Save-Data: on
Request:
GET /image.jpg HTTP/1.0 Host: example.com Save-Data: on
Response:
HTTP/1.0 200 OK Content-Length: 102832 Vary: Accept-Encoding, Save-Data Cache-Control: public, max-age=31536000 Content-Type: image/jpeg [...]
Without Save-Data
Request:
GET /image.jpg HTTP/1.0 Host: example.com
Response:
HTTP/1.0 200 OK Content-Length: 481770 Vary: Accept-Encoding, Save-Data Cache-Control: public, max-age=31536000 Content-Type: image/jpeg [...]
Specifications
Specification |
---|
Save Data API # save-data-request-header-field |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
Save-Data |
49 |
≤79 |
? |
? |
35 |
No |
49 |
49 |
? |
35 |
No |
5.0 |
See also
- Help Your Users `Save-Data` - CSS Tricks
- Delivering Fast and Light Applications with Save-Data - Google Developers
-
Vary
header which indicate that the content served varies bySave-Data
(see HTTP Caching > Varying responses) - CSS @media feature
prefers-reduced-data
- Adapting to Users with Client Hints (developer.google.com)
- Network client hints
NetworkInformation.saveData
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Save-Data