Header image

Symfony Finland
Random things on PHP, Symfony and web development

HTTP/2 Server Push with Curl in PHP 7.1

HTTP/2 is here today and growing constantly. As PHP remains the the most common language for creating web sites and web applications with tools like WordPress and Drupal, it is integral that it keeps up to date with the latest web technologies.

PHP 7 already comes with some support for HTTP/2 specific features, but now there is a new proposal for server push in PHP up for review using HTTP/2. Davey Shafik has written an RFC that aims for exposing the new Server Push features from libcurl to the userland in PHP 7.1:

Server push allows the server to push additional resources relevant to the requested resource directly to the client proactively. This allows developers to push render critical assets such as stylesheets or initial JSON data payload for single page applications.

Considering how far the original HTTP has been stretched from it's context it is likely that there is a wealth of ways that Server Push will be used in the future on the web.

PHP 7.0.0 is close to a release with the hopes that the current Release Candidate (RC7) is the final one, so it'll take a while before this functionality would be native in PHP, but in the meanwhile you can go ahead and simply send the headers with the Symfony HttpKernel, for example: HTTP/2 Server Push with the Symfony HttpKernel

It is good to see active development of PHP 7 already before the launch. Like in many other projects, less is more and adding features such as server push in a planned point release is a great way forward.

Read more about HTTP/2:

Written by Jani Tarvainen on Thursday November 19, 2015
Permalink - Tags: php, http2

Leave a comment

comments powered by Disqus

« Popular Symfony components used by CMSes - Open Source and the Content Creation Experience »