What is HTTP header, how do they work, and how are they useful to you?
A technical guide for developers, for all those who are trying to understand servers on a more detailed level, naive clients arguing with their devs, or randomly bored people with nothing else to do in their life.
What is an HTTP header?
HTTP headers, an essential component of every communication between web servers and browsers, carry various information between them.
When your browser visits a website…it sends an HTTP request to the (web) server. Which includes HTTP request headers with info like:
- What URL you’re requesting. – https://somesite.com/abcpage
- If your visit is referred from another page.
- What browser you’re using – Chrome, Firefox, etc.
- What language set in your browser – English, Spanish, etc.
- What things your browser can cache – css, images, etc.
- See full list of HTTP request fields.
In short, request headers give the server useful information about yourself (your computer, your browser, what info you want, and how you’re able to process it).
So, what exactly is an HTTP header?
HTTP headers are essentially small packets of information that are exchanged between web servers and browsers during every communication.
When your server returns the website…it sends an HTTP response to your web client (browser). Which includes HTTP response headers with info like:
- Status of the URL – 200 (working), 301 (redirected), 404 (not found), 500 (server not working), etc. See all HTTP status codes.
- What web server – Apache, NGINX, LiteSpeed.
- Caching info – if the page is cached, if it’s using CDN, etc.
- Content-encoding – GZIP, Brotli.
- Content type – HTML, text, etc.
- Age of the cached content – so your browser knows whether to download new info or not.
- What type of content can be executed in the browser – videos, PDF, etc.
- What browser features can be used – microphone, camera, etc.
- See full list of HTTP response fields.
In short, response headers give the browser useful information about the website and specifies how your browser is allowed to use (or engage with) that website.
Here’s how it works: when you visit a website, your browser sends an HTTP request to the web server, which includes HTTP request headers with information such as the URL you are requesting, the browser you are using, the language set in your browser, and the data your browser can cache, among other things.
In simpler words, these headers offer useful information to the server about yourself, your computer, your browser, the data you want, and how you’re able to process it.
When your web server responds to your request, it sends an HTTP response to your browser, which includes HTTP response headers containing information like the status of the URL, what web server it is running on, content-encoding, content type, the type of content that can be executed in the browser, and what browser features can be used, among other things.
Essentially, these response headers offer your browser useful information about the website and specify how your browser can interact with it.
But how can you check the HTTP headers sent? To see the HTTP request headers sent from your browser, you can use a tool such as “What’s My Browser Headers.” It shows you what HTTP request headers your browser is sending and provides detailed client hints, including screen size, connection type, and preferred color schemes.
But why are HTTP headers essential? HTTP headers facilitate the sharing of information between servers and clients. While the average web user is unaware of the fact that HTTP headers are sent in the background with every request and response, website owners rely on them to communicate with servers effectively.
How can I see what HTTP headers are sent?
How to see what HTTP request headers are sent from your browser:
- This awesome tool shows what HTTP request headers your browser is sending.
- Or also the more detailed client hints your browser is sending. Shows screen-size, connection type, if you prefer LIGHT or DARK color schemes.
How to see what HTTP response headers are sent from the website:
- Open up the Developer Tools in your browser. (Can do it by right-clicking anywhere on the page and click “Inspect”.)
- Reload the page, and then click on “Network” tab and then “Headers” tab.
- Then scroll through the headers and check out what useful info is shown
If you want to see the HTTP response headers sent from the website, you can open the Developer Tools in your browser. Then, reload the page, click on the “Network” tab, followed by the “Headers” tab, and scroll through the headers to view the information shown.
Although the typical user does not need to know what HTTP request headers are sent from their browser, they might want to modify the headers sent out to enhance their privacy and security or use a private browser.
Now you know what is HTTP header!
Now you understand when website guides talk about “cache headers”, “security headers”, “response header” or “request header”…they’re all just referring to HTTP headers. (And obviously…not talking about “HTML headers” which is the top of your website page.)
In conclusion, HTTP headers play a critical role in web communication, making it easier to exchange information between servers and clients.