ComputersNetworks

What is http header?

Using http headers, there is an exchange of service 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.

What are http headers?

"Hypertext Transfer Protocol" - this is how the http header is translated. Due to its existence, the client-server communication is possible. If to explain in simple words, the browser user sends a request, initiating connection with 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 site address is printed in the appropriate line, 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.

Browser and site interaction

The scheme of interaction between the browser and the site is quite simple. 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 request for the http header field. 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 version of protocol and http.

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

HTTP Caching

The bottom line is that caching ensures the storage of HTML pages, other files in the cache (a place in the operating memory, on the hard drive 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 and a proxy 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 significantly speed up the site, but also provide an older version of the page. By caching the site , headers are sent to the response. In this case, the information requested by the HTTPS protocol can not be cached.

Description of http headers

One of the most important cache mechanisms is the http 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 link category. They are not cached by default. For the cache to work correctly, each URL must match one content variant. If the page is in two languages, each version must have its own URL. The vary header tells the request header header cache. 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 required 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.

In total, there are four groups of headers that transmit service information. These are the main headers - they are contained in any server and client messages, a request and a response, as well as an entity. The latter describe the content of any message from the client and the server.

The HTTP authorization header is considered optional. When a 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".

How to 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, choose the developer tools (net works).

When 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.

The structure of the http response

The server responds to client requests with long messages. 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 a code of 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 you must enter to confirm the login.
  5. About denied access, says code 403. Barring views, downloading files or videos is a common response on the Internet.
  6. There are also other versions of the codes: temporary movement 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 and the server. 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 for secure https connection 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.

Useful recommendations

Active users of computers and developers do not want to get acquainted with some professional recommendations 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 the download of a new, not obsolete document.
  • 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.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.atomiyme.com. Theme powered by WordPress.