Enables HTTP/2 server push for local JavaScript and CSS resources.
FAQ
Installation Instructions
Install HTTP/2 Server Push automatically from your admin account by selecting “Plugins”, then “Add new” from the sidebar menu. Search for HTTP/2 Server Push, then choose “Install Now”.
or
Download the latest HTTP/2 Server Push plugin archive from wordpress.org. Unzip the archive and upload the http2_server_push directory to the /wp-content/plugins/ directory on your WordPress site. Activate the plugin through the ‘Plugins’ menu in WordPress
What if my web server doesn’t support HTTP/2 or “server push”?
Server push is triggered by the same mechanism as link prefetching, which almost all major modern browsers support over HTTP 1.x. So even if you can’t take advantage of HTTP/2’s features, people visiting your site may still get a better experience from prefetching.
How do I know if this is working?
There are a couple ways:
- nghttp is an HTTP/2 client that ships with the nghttp2 suite.
nghttp -v http://example.com
will show all the HTTP/2 signalling packets, HTTP headers, content, and resources sent from the server in a single request. You can see PUSH PROMISE
signals from the server and the pushed resources after the main page is sent.
- In Google Chrome, chrome://net-internals/#spdy will show a history of server connections from the browser. Clicking on a connection will show the discussion between the browser and the server. Within that text, you can see
PUSH PROMISE
packets and the pushed resources.
How can I help with development and testing?
The source code is available at https://github.com/daveross/http2-server-push. Issues and pull requests are welcome and encouraged!
ChangeLog
1.0
1.1
- Fix errors starting the output buffer through the template_redirect action
1.2
- Support for protocol-relative URLs
- Implemented “resource hints” to encourage preload/prefetch behavior when HTTP/2 support is lacking.
- Fixed ‘as’ value to match latest W3C specs
1.3
- Doesn’t render resource hints when WordPress native support is present
- No longer pushes assets on admin pages
- Limits HTTP/2 Server Push headers to 4k to help alleviate 520 errors when used with Cloudflare
1.4
- Uses site_url instead of home_url for better WPML compatibility
- Tested up to WordPress 4.9.4