Sec-CH-UA-Mobile Header
Table of Content
The Sec-CH-UA-Mobile header is a type of client hint header that enables the server to understand the mobile-related preferences of the user-agent, by specifying if the user-agent is for a mobile or a desktop device. This allows the server to optimize the content that is sent to the client.
Syntax
Sec-CH-UA-Mobile: ?0 // For desktop browsers
Sec-CH-UA-Mobile: ?1 // For mobile browsers
Directives
The Sec-CH-UA-Mobile header accepts either "?0" or "?1" as directives. "?0" indicates that the user-agent is for a desktop device. On the other hand, "?1" indicates that the user-agent is for a mobile device.
Examples
If the user-agent represents a mobile device, the server might receive a request header along these lines:
Sec-CH-UA-Mobile: ?1
On the other hand, if the user-agent represents a desktop device, the request header might look like this:
Sec-CH-UA-Mobile: ?0
Browser Compatibility
Browser | Compatibility |
---|---|
Chrome | Supported |
Firefox | Not Supported |
Safari | Not Supported |
Opera | Supported |
Edge | Supported |
How to modify Sec-CH-UA-Mobile header
ModHeader is a browser extension that allows users to modify request headers. With ModHeader, you can add, modify, or remove a Sec-CH-UA-Mobile request header. Here's how:
- Install the ModHeader browser extension.
- On the ModHeader UI, select the "Request headers" tab.
- Click on the "+" button to add a new header.
- In the "Name" field, type
Sec-CH-UA-Mobile
. - In the "Value" field, type
?0
or?1
, depending on whether you want the user-agent to represent a desktop or mobile device.
This manipulation is useful, especially during debugging and testing. For example, you can change the Sec-CH-UA-Mobile header to test how your website or web service behaves on both mobile devices and desktops.