/ / What is the http header?

What is the http header?

С помощью заголовков http происходит обмен 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 about the tasks of the http headers will seem rather complicated, but in fact they do not contain difficult formulations. This is what the web user encounters daily.

http header

What are http headers?

«Протокол передачи гипертекста» – именно так http header is translated. Thanks to its existence, client-server communication is possible. If explained in simple terms, the browser user sends a request, initiating a connection to the server. The latter, by default, waits for a request from the client, processes it and sends back summary information or a response. In the search box, the user “drives in” the address of the site, which starts with http: // and gets the result in the form of the opened page.

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

In general, http headers are quite effective.They are not visible in the 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 function header.

ttp accept header

Interaction between the browser and the site

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

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

  • starting line (message type);
  • headers (message parameters);
  • body information (message, which is separated by an empty line).

The start line is a required element of the request for the http header field. The structure of the user request consists of three main parts:

  1. Method. It specifies the type of request.
  2. Path. This is the URL string that follows the domain.
  3. Used protocol. It consists of the protocol and http versions.

Modern browsers use version 1.1. The following are 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 (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 you send a message to the URL, the browser checks for an object in the cache. If there is no object, the request is transmitted 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 is not only capable ofspeed up the site, but also provide the old version of the page. Using site caching, headers are sent to the response. However, the information requested via the HTTPS protocol cannot be cached.

http header fields

Description http headers

Одними из самых главных механизмов кеша считаются http expires headers These headers report the expiration date provided in the response information. They indicate the time and date when the cache will be considered obsolete. For example, such a headline 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.

Http proxy headers are classified as headerlink. They are not cached by default. For the cache to work correctly, each URL must correspond to one content variant. If the page is bilingual, each version must have its own URL. The vary header tells the cache the headers of the request. For example, if the display of the request depends on the browser, the server also needs to send a header. Thus, different variants of requests and document types are saved in the cache. The TTP accept header is necessary in order to make lists of acceptable formats for the used resource, it is rather easy to work with it, as it eliminates unnecessary ones.

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

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

http proxy headers

How to see the headlines?

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

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

When the plugins are installed, launch them and refresh the browser page.

Query methods

Methods that are used in HTTP are similar to instructions that are sent as a message to the server. This is a special word in English.

  • GET method. It is used to request information from the resource. All actions begin with it.
  • POST. It is used to send data. For example, a message in a social network or a comment, the browser places in the body of a POST request and sends it to the server.
  • HEAD.The method has similarities with the first, but performs an easy function. It requests only meta data, excluding the message from the response. The method is used if they want to get information about files without downloading. It is used if they want to check the functionality of links on the server.
  • PUT. Uploads data to a URL. Transmits large amounts of data.
  • OPTIONS. Works with server configurations.
  • URI. Identifies the resource and contains the URL.

http protocol header

HTTP response structure

Server responds to client requests with longmessages. The answer consists of several lines indicating the protocol version, server status code (200). He talks about what has 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 query indicate other information about the information transmitted.
  2. If the file is not found or does not exist, the server sends the code 404 to the client, it is also called an error.
  3. Code 206 indicates a partial file download that can be resumed after a while.
  4. Code 401 indicates a denial of authorization. This means that the requested page is protected by a password that must be entered to confirm the entry.
  5. About the forbidden access, says code 403. Bans on viewing, downloading files or videos - a common answer on the Internet.
  6. There are also other versions of the codes:temporary move of the requested file, internal server error, final move. In this case, the user will be redirected. If code 500 appears, it means that the server has crashed.

URL - what is it?

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

The protocol is also available for securehttps connections and information sharing. The URL contains information about the location of a particular site on the Internet. The address includes the domain name, the path to the page, as well as its name.

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

http expires headers

Useful recommendations

Active computer users and developers should not get acquainted with some professional recommendations that experts in this field give:

  • Mark the expiration date of files and documents, taking into account updates. Statistical information is indicated in large values ​​of max-age.
  • A separate document should be available only at one URL.
  • If you update the file that will be downloaded by the user, change its name and link to it. This ensures downloading a new, not outdated document.
  • Last-Modified headers should correspond to the present date of the latest content changes. Do not resave pages and documents if you do not change them.
  • Use POST requests only where it is needed. Minimize the use of SSL.
  • Headers should be checked by the REDbot plugin before being sent by the server.
Liked:
0
Popular Posts
Spiritual development
Food
yup