/ / What is http header?

What is http header?

With the help of the http headers, an exchangeservice information between the client and the server. This information remains invisible to users, but without it, the correct operation of the browser is impossible. For ordinary users, information about this and the tasks of http headers will seem rather complicated, but in fact they do not contain difficult formulations. This is what a web user is facing every day.

http header

What are http headers?

"HyperText Transfer Protocol" - exactly sothe http header is translated. Due to its existence, client-server communication is possible. If to explain in simple words, the browser user sends a request, initiating a connection to the server. The latter, by default, waits for the request from the client, processes it and sends back the summary information or response. In the search box, the user "hammers" the address of the site, which begins with http: // and gets the result as an opened page.

When the address of the site is printed in the correspondingline, the browser finds the required server using DNS. The server recognizes the http header (one or more) that the client sends to it, and then issues the required header. The mandatory set consists of already existing headers and not found.

In general, http headers are quite effective. They are not visible in HTML-coding, they are sent before the requested information. Many headers are automatically sent by the server. In order to send it in PHP, you should use the header function.

ttp the accept header

Browser and site interaction

The scheme of interaction between the browser and the site is sufficientsimple. So, the http header starts the query string, which is then sent to the server. In response, the information needed by the client comes. By the way, http protocol is already seventeen years old - the most used on the Internet. It is simple, reliable, it works quickly and flexibly. The main task of http is to request information from the web server. The client is the browser, and the server is ligthttp, apache, nginx. If the connection between them is successful, the server receives the requested information in response to the request. The http information contains text, sound files, video.

The protocol can be a transport for others. The customer request consists of three parts:

  • the start line (message type);
  • headers (message parameters);
  • body of information (a message that is separated by an empty line).

The start line is the required element of the http header request. The structure of the user's request consists of three main parts:

  1. Method. It indicates the type of request.
  2. The path. This is the URL string that follows the domain.
  3. The protocol used. It consists of the protocol version and http.

Modern browsers use version 1.1. Next, headings in the format "Name: Value".

caching http headers on the nginx server

HTTP Caching

The bottom line is that caching provides storageHTML-pages, other files in the cache (a place in the operating memory, on the hard disk of the computer). This is necessary in order to speed up access to them and save traffic.

The cache has a client browser, an intermediate gateway andproxy server. Before sending a message to the URL, the browser will check for the presence of the object in the cache. If the object does not exist, the request is passed to the next server, where the caching of http headers on the nginx server is checked. Gateways and proxies are used by different users, so the cache is shared.

HTTP caching can not only significantlyspeed up the site, but also provide an older version of the page. By caching the site, headers are sent to the response. The information requested by the HTTPS protocol can not be cached.

http header fields

Description of http headers

Some of the most important cache mechanisms arehttp headers expires. These headers report the expiration date of the information provided in the response. They specify the time and date when the cache will be considered obsolete. For example, this header looks like this: Expires: Wen, 30 Nov 2016 13:45:00 GMT. This structure is used almost everywhere, including for caching pages and images. If the user selects the old date, the information will not be cached.

The http proxy headers are in the header categorylink. They are not cached by default. For the cache to work correctly, each URL must match one content option. If the page is in two languages, each version must have its own URL. The variable header reports the header of the request header. For example, if the query display depends on the browser, the server must also send a header. Thus, the cache stores various query options and document types. The TTP accept header is needed to compile lists of valid formats for the resource being used, it is easy enough to work with it, since it filters out unnecessary ones.

There are four groups of headings,which transmit the service information. These are the main headers - they are contained in any server and client message, request and response, as well as the entity. The latter describe the content of any message from the client and the server.

The HTTP authorization header is consideredadditional. When the web page asks the client for authorization, the browser displays a special window with fields for entering the login and password. After the user enters their data, the browser sends an http request. It contains the title "authorization".

http proxy headers

How can I see the headers?

To see the http header, you need to install plugins for the browser, for example, firefox:

  • Firebug. You can view the headers in the net tab, where you select all. This plugin has functions that will be useful to the web developer.
  • Live http headers. A simple plugin designed for viewing http headers. Using it, you can manually generate a query.
  • Ghrome users will easily see the headers if they click the settings button, select the developer tools (net works).

When the plug-ins are installed, run them and refresh the browser page.

Query methods

The methods used in HTTP have similarities to the instructions that are passed as a message to the server. This is a special word in English.

  • Method GET. It is used to request information from a resource. It is with him that all actions begin.
  • POST. With it, the data is sent. For example, a message on the social network or a comment the browser places in the body of the POST request and sends it to the server.
  • HEAD. The method has similarities to the first, but performs an easy function. It only requests meta-data, excluding the message from the response. Use this method if you want to get information about files without downloading. It is used if you want to test the efficiency of the links on the server.
  • PUT. Loads data into the URL. Sends large amounts of data.
  • OPTIONS. Works with server configurations.
  • URI. Identifies the resource and contains the URL.

http protocol header

The structure of the http response

The server responds to client requests with longmessages. The answer consists of several lines, in which the protocol version is indicated, the server status code (200). It says that it changed on the server during the processing of the incoming request:

  1. The status of "two hundred" indicates the successful processing of information. After that, the server sends the document to the client. The remaining lines of the request indicate other information about the information being transferred.
  2. If the file is not found or does not exist, the server sends the client code 404, it is also called an error.
  3. Code 206 indicates a partial download of the file, which can be resumed after a while.
  4. Code 401 indicates a denial of authorization. This means that the requested page is password protected, which must be entered to confirm the login.
  5. About forbidden access, says the code 403. Prohibitions on viewing, downloading files or video is a common response on the Internet.
  6. There are also other versions of the codes: temporary relocation of the requested file, internal server error, final move. In this case, the user will be redirected. If the code 500 appears, it means that the server has malfunctioned.

URL - what is this?

URL is the heart of web communication between the client andserver. The request is usually sent via URL - a single resource index. The structure of the url request is very simple. It consists of several elements: http protocol (header), hoot (site address), port, resourte path and query.

The protocol is also available forhttps connections and information exchange. The URL contains information about the location of a specific website on the Internet. The address includes the domain name, the path to the page, and its name.

The main disadvantage of working with URLs is inconvenient interaction with the Latin alphabet, as well as numbers and symbols. In SEO optimization, the url address plays an important role.

http headers expires

Useful recommendations

Active users of computers and developers do not want to get acquainted with some professional recommendations that are given by specialists in this field:

  • Designate the expiration dates for files and documents, taking into account updates. Statistical information is indicated in large values ​​of max-age.
  • A single document must be accessible only by one URL.
  • If you update a file that will be downloaded by the user, change its name and a link to it. This ensures that a new, not obsolete document is downloaded.
  • The Last-Modified headers must match the current date of the most recent content changes. Do not re-save pages and documents, if you do not change them.
  • Use POST-requests only where it is needed. Minimize the work with SSL.
  • Headers before sending the server should be checked with the plugin REDbot.
  • </ ul </ p>
Read more: