Always be one step ahead, predict what will be needed, and offer it even before you’ve been asked — this is the secret of business success, especially in the 21st century. This is also the principle of work of HTTP/2 Server Push, the technology we will consider today as one of the options to optimize your website’s loading speed.
HTTP/2 and its secrets
First of all, let’s take a look at HTTP/2, the latest version of the well-known protocol. Just switching to it, with no changes to the code or other “magic tricks,” can give websites a noticeable performance boost.
So what makes HTTP/2 beneficial as compared to its predecessor, HTTP/1.1? The two main reasons are the single TCP connection and the Server Push concept.
Single TCP connection
HTTP/1.1 operates numerous TCP connections to handle numerous requests, which may lead to website performance losses.
Luckily, HTTP/2 addresses this problem by using only one TCP connection for all requests, allowing all responses to be sent in parallel over this connection. The server and the browser communicate through so-called streams marked with IDs, which is much faster.
HTTP/2 Server Push
There is another exciting new concept in HTTP/2 called Server Push. Today, most websites use various types of resources like HTML, stylesheets, and scripts (index.html, styles.css and script.js). Traditionally, when a browser makes a request to the server, it fetches and parses the HTML first, then discovers it also needs JavaScript and CSS and makes follow-up requests. These round trips make the server yawns waits patiently, while the network stays pretty idle.
HTTP/2 Server Push is here to change the rules of the game. It allows the server to predict what other resources will be needed and send (or push) them preemptively, without waiting for the browser to request them. So, while the browser parses the HTML, other files (JavaScript and CSS) are getting ready. This approach leads to a loading speed increase.
In other words, the server takes the initiative to provide more after the browser’s initial request. In addition, popular items for pushing include the next pages a visitor will probably go to, redirects, and more.
PUSH_PROMISE frame
The server makes promises and fulfills them with HTTP/2 Server Push. Before the pushing process, it prepares a PUSH_PROMISE frame describing what resources that are going to be sent, so the browser knows what to expect.
A wise approach
For good results, using HTTP/2 Server Push requires some careful planning. For example, you should push with care, and only push what will be really needed. It is also necessary to take care of the proper caching of the pushed assets and make sure they are not forced upon browsers again and again.
HTTP/2 Server Push can be a truly powerful speed-gaining tool when managed right. Contact us and we can help you make the best use of all its capabilities. We know what you expect before you even ask. And we will deliver it to you! We promise ;)