HTTP/2 Server Push plugin for WordPress
I developed a plugin which sends link header for HTTP/2 Server Push.
https://github.com/tarosky/http2-server-push-preload
Did you feel my blog is faster? Yes, this plugin is working on this site. đŸ™‚
HTTP/2 Server Push which is defined in the HTTP/2 specification, allows a server to push resources, for example CSS and JS, images.
https://tools.ietf.org/html/rfc7540#section-8.2
My plugin gets a list of the CSS and JS which are queued via wp_enqueue_script()
and wp_enqueue_style()
.
And it sends link:
response header which enables to pre-load those resources like following.
Link: ..., </wp-content/themes/example/style.css>; rel=preload; as=style, ...
Unfortunately, this plugin needs some requirements to work.
- Nginx 1.13.9 or later
- WordPress 4.9 or later
- PHP 7 or later
But I guess you can use this plugin on the Cloudflare with zero configuration.
https://blog.cloudflare.com/announcing-support-for-http-2-server-push-2/
If you are a Cloudflare user, please download latest version from following URL and install it into your WordPress.
https://github.com/tarosky/http2-server-push-preload/releases
And please verify with command line like following.
$ nghttp -nv https://example.com/ | grep PUSH_PROMISE
If it works fine for you, you can see the output it contains `PUSH_PROMISE`.
[ 0.217] recv PUSH_PROMISE frame <length=76, flags=0x04, stream_id=13> [ 0.217] recv PUSH_PROMISE frame <length=84, flags=0x04, stream_id=13> [ 0.217] recv PUSH_PROMISE frame <length=75, flags=0x04, stream_id=13> [ 0.217] recv PUSH_PROMISE frame <length=103, flags=0x04, stream_id=13> [ 0.217] recv PUSH_PROMISE frame <length=108, flags=0x04, stream_id=13> [ 0.217] recv PUSH_PROMISE frame <length=61, flags=0x04, stream_id=13> [ 0.217] recv PUSH_PROMISE frame <length=90, flags=0x04, stream_id=13> [ 0.217] recv PUSH_PROMISE frame <length=90, flags=0x04, stream_id=13> [ 0.217] recv PUSH_PROMISE frame <length=89, flags=0x04, stream_id=13> [ 0.217] recv PUSH_PROMISE frame <length=99, flags=0x04, stream_id=13>