This site uses cookies and other tracking technologies to make possible your usage of the website, assist with navigation and your ability to provide feedback, analyse your use of our products and services, assist with our promotional and marketing efforts, and provide better user experience.

By using the website, you agree to our Privacy policy

Accept and continue

Report a bug

Cancel
150
How-to 7 min read September 5, 2019

How to reduce the number of HTTP requests

HTTP requests send a message to the server that the user sends. They are reduced by combining components, pictures, caching, separation of components by servers, and other methods.

What are HTTP requests and why do they need

HTTP requests are the protocols with the help of which data is exchanged on the Internet during client-server interaction. The browser sends these protocols when displaying web pages. While responding to a request, the server sends the appropriate files. That is, an HTTP request is a request from the browser to the server.

By showing the user a simple web page on a site, the browser can send up to a dozen requests. Below is an example where 4 HTTP requests were sent when the page was displayed:
HTTP requests in page code

Why does the speed of loading documents decrease due to HTTP requests

Increasing the amount of data

During the download, the value of the response header and the amount of transmitted data are important. Headings usually include:

  • web browser version;
  • supported data formats;
  • desired language for displaying content
  • selected compression algorithms;
  • information about the selected encoding;
  • cookies
  • POST / GET information, etc.

Up to 40 requests can be sent to download colorful, thoughtful web pages. And if about 1000 bytes are required to show one component, then the total size will be up to 40 000 bytes or 40 Kb.

How to calculate the number of HTTP requests when loading web pages

The indicator can be viewed in browsers.

Mozilla Firefox

In Firefox, use the extension Firebug. It is effective, but in most browsers there are built-in analogues that have no less effective functionality.

To use the extension:

  • go to the "Network" section;
  • refresh the web page;
  • check the number of requests below.
Number of HTTP requests in Firebug plugin in Firefox

Opera and Google Chrome

These two web browsers have built-in counting tools. To use them:

  • open your website in them;
  • right-click anywhere in the document and select "Explore Component";
  • go to the "Network" tab;
  • refresh the web page to see the exact number of requests below.

How to reduce the number of HTTP requests

Combining components

By combining components for downloading into a single file, specialists reduce their number. Consequently, the number of HTTP requests is reduced. If 3 stylesheets and 4 JavaScript scripts are connected, 8 requests will be sent (7 + 1 for HTML code).

To minimize the indicator, it is enough to collect style sheets in one file, and libraries in another. So the number of requests will decrease from 8 to 3.

You can use special tools, for example, Minify. By the way, the application minimizes not only statics, but also HTML. It is written for PHP.

When combining JavaScript scripts, you may encounter difficulties with those scripts that use the method document.write to display part of the text.

To eliminate the inconvenience, you have to modify these sections of code by removing document.write. Or do not combine such a script with others.

Combining SVG images

SVG is a special vector graphics format. The advantage of the format is that it can be edited in standard editors, but it will also be textual. This means that it can be opened through any code editor text.

For example:
<svg width="20">
  <rect fill="#fc0"
    width="20"
    height="20"/>
  <line stroke="black"
    x1="0" y1="0"
    x2="20" y2="20"/>
</svg>
This format is suitable for graphics that design content.

Previously, the method was popular CSS sprite. With it, to load the required component of the web page, the properties background-image, background-position were used.

One of the options for using CSS sprite:
Using CSS sprite to combine images
They made such pictures manually or through spritegen. But this technology is already outdated; more and more webmasters prefer SVG images. The main reason is precisely that the images are set only of a certain size, but for the "rubber layout" this is not relevant.

This technology has disadvantages:

  • The development process is becoming more complicated. A mile of the page, it is necessary to consider differences of elements when displaying in different browsers.

  • The upgrade process is getting more complicated. If you need to remove or modify one graphic component, you have to edit the entire picture.
  • There is a risk of slower page loading. This happens if sprites are applied incorrectly.

  • CSS sprites are missing their URLs. If a visitor displays a graphic in a web browser, nothing will load in the place of such images.

Caching

To implement this method, the information on the server must match the cache data. As most of the downloadable components are static, a declarative expiration date is used as a suitable caching method.

To enable the mode, just put the .htaccess file in the www.domain.tld / res / folder with the instructions:
htaccess caching
In this case, the file will not be reloaded from the server until the date selected in the third line.

Distribution of components between servers

The speed of display of elements is limited by the bandwidth of the data channel. To speed up the process, you can use parallel downloads.

What else affects the number of HTTP requests

Plugins can affect metrics. Each of them has its own styles and scripts. Plugins register links to these elements to each web page, which increases the number of requests.

The following shows how this happens with the WP Subscriber Form plugin as an example:
Impact of WordPress Plugin on HTTP Requests
Custom CSS and JavaScript files can contain themes.

Conclusion

HTTP requests are an integral element of data transfer during client-server access. If web documents load too long, visitors can leave them without waiting for the information to be displayed. To reduce the latency of downloads, minimize requests.

The most popular ways to reduce HTTP requests:

  • combining elements — style sheets, JavaScript libraries;
  • association of pictures;
  • Inline pictures;
  • caching
  • distribution of components between servers.

This article is a part of Serpstat's Checklist tool
Checklist at Serpstat
Checklist is a ready-to-do list that helps to keep reporting of the work progress on a specific project. The tool contains templates with an extensive list of project development parameters where you can also add your own items and plans.
Try Checklist now

Learn how to get the most out of Serpstat

Want to get a personal demo, trial period or bunch of successful use cases?

Send a request and our expert will contact you ;)

Rate the article on a five-point scale

The article has already been rated by 0 people on average out of 5
Found an error? Select it and press Ctrl + Enter to tell us

Share this article with your friends

Sign In Free Sign Up

You’ve reached your query limit.

Or email
Forgot password?
Or email
Back To Login

Don’t worry! Just fill in your email and we’ll send over your password.

Are you sure?

Awesome!

To complete your registration you need to enter your phone number

Back

We sent confirmation code to your phone number

Your phone Resend code Queries left

Something went wrong.

Contact our support team
Or confirm the registration using the Telegram bot Follow this link
Please pick the project to work on

Personal demonstration

Serpstat is all about saving time, and we want to save yours! One of our specialists will contact you and discuss options going forward.

These may include a personal demonstration, a trial period, comprehensive training articles & webinar recordings, and custom advice from a Serpstat specialist. It is our goal to make you feel comfortable while using Serpstat.

Name

Email

Phone

We are glad of your comment
Upgrade your plan

Upgrade your plan

Export is not available for your account. Please upgrade to Lite or higher to get access to the tool. Learn more

Sign Up Free

Спасибо, мы с вами свяжемся в ближайшее время

Invite
View Editing

E-mail
Message
Optional
E-mail
Message
Optional

You have run out of limits

You have reached the limit for the number of created projects. You cannot create new projects unless you increase the limits or delete existing projects.

I want more limits