HTTP Headers in Web Development - How Headers Are Used (
Page 3 of 4 )
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:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
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.