PHP 7 and HTTP2: To Speed Up Website Load Process

The evolution of PHP for its seventh version occurred six months ago and it is already possible to observe its performance and impacts, improved memory savings and some changes for users.

With the evolution of language, there was also breaks paradigms, such as, for example, the depreciation of the tags. This depreciation can cause breaks compatibility between versions, especially the most unsuspecting users who have not made the migration from version four to version five.

William Blanco mentioned in his speech that another important factor is the new combinations of operators, which enabled the creation of new operators and also broke with some old. An example of a new operator is  coalesce null, which allows you to check if a variable or key array exists and assign a value if it does not exist.

A very important point is that, now all errors are considered exceptions, including fatal errors and parse, and so you start to have more control of what is wrong with your code, and how you should handle this error.

The big development was due to the internal changes. PHP 7 has a new memory management, which led to an optimization of its consumption. It is also possible to observe greater security on threats and optimization of the data structure.

The memory of all the internal changes was the one that drew the most attention. With the reduced number of allocation, it works faster. The speed of PHP7, compared to 5.6, is almost double, and helps to compile just in Time. This new memory management is one of the first steps towards the future observed by Ben Ramsey.

Ben is one of the most passionate figures for the PHP community. He is the founder of Atlanta PHP Group and the PHP nashvile co-organizer, in addition to contributing to the libraries of language. He was present at PHP Experience 2016 and commented on the future of HTTP. According to Ben, HTTP1.1 was upgraded to the HTTP 2.0 due to the growth of the web and the creation of new RFC’se protocols.

Currently, the number of objects sent via the web is great. And besides the objects, we also have a number of requests and the growing number of users. These increases have generated problems such as latency, queue management among others.

According to Ben, the HTTP2 came in order to correct these problems. But how? 2 handles the HTTP headers torques and tablets, which greatly reduces the amount of data traffic on the network.

In addition, working with HTTP2 parallelization and requests to multiplexing. Today, a web page carries with it several features such as CSS, JavaScript, images and files. And every time a request is made, all these files are downloaded. And this, in HTTP1.1, this is a serial process, i.e. it is only open to new request when it ends the current connection. Although some browsers support HTTP 1.1 open from 4 to 8 simultaneous connections, it ends up being insufficient or time consuming.

In HTTP2.0, the requests and responses are parallel and asynchronous, that is, no matter the order in which the answers arrive. Thus, only one connection is required. How is this possible? Everything is done through the headers. Each request and each HTTP response sends multiple headers at the top of the request. This approach handles the problem of queues.

However, for the process to successfully occur, it is also implemented as a prioritization solution and dependencies that are passed to the browser according to the request of each user.

Finally, we have the server push, whose function is to send files to the browser before it has requested them. That is, the server pushes the browser resources that “know” that he will need for the full page load – which greatly speeds up the process, because the browser will have already cached files and do not need a request.

With all these improvements, can we expect the next version of PHP will be the future of the Internet? We expect more improvements, Isn’t it? And all this because of the communities around the world. The community unit has generated a very high knowledge curve, and this undoubtedly leads to greater knowledge, and most importantly, greater dissemination of it.