Server response

views2496
Difficulty:

When you want to go to a certain site, the browser makes a request to a certain server. In addition to the content of the web page, a lot of important data is stored in the server response. You can see them in different ways, but one of the easiest is to use service from Yandex.

I would like to say right away that not only the content of the server's response is important, but also the time for which the server gives this response. Yandex recommends keeping it within 0.2 seconds. Some CMS (bitrix) on some virtual hostings cannot meet this time. Choose the right software and hosting, optimize the code. If all possible optimizations have already been done, but the server response time is more than 0.2 seconds, then you should think about moving to VDS. It costs a little more than virtual hosting, but the server response speed there will be faster.

Server response codes

Of course, it is correct to write status codes or HTTP status codes, but most use exactly this wording. There are several dozen such codes. I will tell you about the most common of them.

200 OK is the most popular server response code, which means that the server has processed a specific request normally. Site visitors, when loading pages of your site, should receive 200 code for the page itself, as well as for all files that are required for its full display.

301 Moved Permanently - the document has been moved permanently. Previously, the page had one address, and now another. Use redirection to a new address with 301 server response code. 301 redirect is also used when redirecting from non-main page variants to the main one. If one page is available at several addresses and gives 200 code, then it will definitely not bring anything good for indexing and ranking the site. The variants of such 301 redirects depend on the CMS or framework used.

Examples of 301 redirects:

  • with www.site.ru on site.ru - choose the main version of the site, with or without www,
  • with http://site.ru on https://site.ru - we switch to the encrypted https protocol after purchasing an ssl certificate,
  • with site.ru/index.php on site.ru - some cms have duplicate page addresses with various additions,
  • with site.ru/page / on site.ru/page - removing pages with the slash "/" in the address,
  • c site.ru/?id=123 on site.ru/page - some cms can store duplicates of pages by their URLs.

302 Moved Temporarily - the document has been moved temporarily. Unfortunately, such a server response code often appears not on the initiative of the site owner, but in case of technical problems. I have had experience when I was approached with the problem of a significant drop in attendance. It turned out that all the pages started giving the 302 server response code. After correcting the error, positions and attendance began to recover.

304 Not Modified - and this answer on the contrary shows that you are most likely engaged in the site. This status has documents (files) that the web server offers to download to the browser from its cache. They haven't changed since your last visit. That is, a specific page (html document) gives 200 code, and already files (pictures, scripts, etc.), 304 response code ask the browser not to download them again.

404 Not Found - the document was not found. The page or file does not exist. Popular reasons: incorrect link, page or file deleted/renamed, you entered the address incorrectly yourself. The most interesting thing is that you can configure (break) the CMS /framework/ web server so that your pages will open, but the response code will be 404. Search engines will gradually remove such pages from their index and output.

400, 500, 502, 503, 504 - you can combine these codes with one phrase "Server error". Start solving the problem by writing to the hosting and restarting the process/server if you have VDS. The reasons can be very different, starting with the fact that the server cannot withstand the load, ending with programmer errors when writing code.

Text information in the server response

The server response contains not only code, but also textual technical information under different headings. They may also be useful to us for solving problems or getting additional information about the site.

Encoding - use UTF-8. If you have a different encoding, then this is a reason to think.

Server - By default, the web server includes its name and version in the server response. For example, "nginx/1.16.1".

X-Powered-By is a similar optional header that advertises the software used by the server.

Content-Encoding - you can see if gzip compression is enabled.

Cache-Control - configuring file caching. If enabled, the caching period is shown.

Video

Author: Aleksandr Dergunov
Published: 12/20/2019