blog posts

How to fix Make fewer HTTP requests error in GTmetrix

One of the errors we encounter when testing site speed with GTmetrix is ​​the Make fewer HTTP requests error in Yslow GTmetrix, which is related to the high number of HTTP requests. As it is clear from the literal meaning of this error, if you encounter this error, it means the number of requests to load various files such as png., CSS., js, etc., that you use on the site is high. Each file you use on each page is equal to one request that is sent to the server to load it, and if the number of requests is not normal and a large number of requests are made from the server, it will cause you to have problems with the number of visits to the site. And face slow speed.

In this tutorial from the knowledge base, going to introduce how to fix the Make fewer HTTP requests error in Yslow GT Metrics. Using this tutorial, you can reduce the number of HTTP requests on the site. The server’s involvement is also reduced, and finally, it makes your site available faster.

How to fix Make fewer HTTP requests error in GTmetrix

When the request to visit the site is entered into the browser, the browser starts to find the IP server by the ISP company that is your internet provider. After this step, your site, which is located with the domain, receives this request, and after checking the request, it starts. Answering here is the same as loading and sending files that are on the same page. In this step, the request is sent in the form of HTTP; in the first step, the page is loaded as HTML, and after this HTML document is compiled and checked, the files and contents inside it start to be loaded. In this step, various files such as javascript, CSS, images, fonts, etc., will start to be loaded, and a request will be sent to the server for each of these files.

Therefore, it can be concluded that with the high number of HTTP requests, the loading time of the site increases, and if we consider this point of view on a wider level than the number of visitors to a site, it can be said that in a day and night, several thousand people visit the site. If they visit, the total number of HTTP requests from the server may be in the millions, which if the number of requests for each page is high, it will cause the server to become more involved. For this reason, the server may not be able to respond as the number of simultaneous requests increases, and as the number of simultaneous requests increases, the site will become slower. can So, we have to do something to reduce the number of requests to the lowest possible level, and this is also done with tricks that I will explain each of them below.

Fix the Make fewer HTTP requests error in GT Metrics

1. Merge files

The best way to be responsive at a good level is to merge shared files. It means that CSS and JS files should be combined and placed in one file as much as possible. In this case, instead of several requests to load all the site’s style files that are in the form of CSS, this request is sent once, and the entire content of the site’s CSS file is received through one file.

2. Using Minimize request size

Using this method also means reducing the size of the files to the minimum possible by using existing coding changes or online tools. In this case, the files will have a smaller size, and when a request is sent to load the file, it will be loaded faster than the initial size, and the server can look for other requests after providing the file in full to the browser.

3. Using Combine images using CSS sprites

If we find the number of images that are fixed on the site and generally include social networks or link to a specific page, and by combining them in the form of an image using CSS, we can display them with a more optimal structure. In this case, when you show an image, you can specify the desired area with the help of CSS to display smaller images so that other parts are hidden.

4. Use of site cache

Using cache can also be a good choice so that for the period you specify, any request sent for files will be received from the cached memory of the user’s browser instead of being loaded directly through the server. In this case, as long as the files are cached in the user’s system, a request to load the file will not be sent from the server, and this issue can reduce the number of HTTP requests on the site in the best possible way.

The best WordPress cache plugins

5. Using Inline small CSS and JavaScript

In this case, if you have CSS and JS files with shortcodes and less volume, you can merge them instead of using them separately or inline in any part of the site that you need. For example, you may use CSS and JS codes on a special page, such as the bottom page, which you do not need on any other site page. Therefore, you can enter these codes directly on the same page. In this case, the fixed style and JavaScript files will not have a large volume.

Inline small CSS and JavaScript error fix

6. Load JS files in the footer

When you enter a site that uses JavaScript, the browser must read all the JS files and show you the site after executing them based on the coding of these files. In some cases, sites try to make changes in the style files with the help of JavaScript; in which case, if the JavaScript file is loaded earlier, the CSS file must be loaded earlier to execute the commands assigned to it. Otherwise, this will not be done correctly, and after loading the CSS file, the open javascript file may be requested from the server to execute the command to change the style files, which will cause two HTTP requests for the javascript file.

Therefore, it is better to load the files in a place where they will be requested from the server at the last moment, and the best place for this is the site’s footer, where you can load the JS files in the last step of loading the site.

7. Using Serve resources from a consistent URL

This also happens when you use the same file through two addresses. Usually, css and JS files are located in this mode, which is located at the end of the address of the files ?ver=, and to solve duplicate requests, you must disable this mode on the site. Just click on the button below and use the article related to this task.

Fix the error. Serve resources from a consistent URL

8. Using Enable Keep-Alive

Not enabling Keep-Alive means that your server is configured to only respond to one request for the same files at a time. This is completely wrong and causes the site’s loading time to increase greatly. To fix this error, you must make the same files, such as CSS and JS start loading simultaneously. One file does not wait for the previous file to be loaded. After that, it will start loading