At this point, you may not know what HTTP headers are, but you use them all the time, both as an Internet user and as a web developer, even if you are not aware of it. The beginning of this article is a short introduction to HTTP headers, including what they are, and what they do. Later in the article, we cover some common uses of HTTP headers in web development.
This is nice to know, but how can it be used? Is there some way to set the HTTP response headers? Can one just put them at the top of a web page?
We will address these questions in reverse order.
Can one put HTTP headers at the top of a web page? Not as such, but there is a Meta tag that can be used in the head section of a web page that provides the same functionality, and uses the same syntax. This is the http-equiv tag. This is an example:
Notice that it looks very similar to the Content-Type: header in the response that was returned by Google in the example above.
Is there some way to set the "real" HTTP response headers? There are two ways to set them. The first is to set them in the server configuration directives. And the second method is to set them using a web scripting language such as PHP, or Perl.
How can HTTP headers be used in web development? There are numerous uses, both for communication between web page and browser, and communication between web pages.
In the next section, I will provide you with a few examples of the many uses of HTTP headers.