Skip to content

What is HTTP/2 and how to enable it in WordPress?

Introduction to HTTP/2

HTTP/2, the second version of HTTP (HyperText Transfer Protocol), is a new network protocol specification that was officially approved and published in 2015. It is a standard for communication between web browsers and web servers.

The most important features of HTTP/2 are:

  • Multiple exposure: HTTP/2 allows you to download data multiple times using a single TCP connection, which significantly speeds up page loading.
  • Stream prioritization: In HTTP/2, you can prioritize different data streams, which means that the most important data can be sent to the client first.
  • Header compression: HTTP/2 introduces header compression, which can save bandwidth and speed up page loading.
  • Push server: HTTP/2 allows servers to "push" resources into the browser's cache, which speeds up page loading.

Enabling HTTP/2 on your WordPress server

To take advantage of the benefits of HTTP/2, you must first make sure that your server supports this protocol. Most modern web servers such as Apache, Nginx, and IIS already support it. If we are unsure whether our server supports HTTP/2, we can check it using online tools such as HTTP/2 Test.

However, please remember that simply enabling HTTP/2 on the server does not guarantee that all connections to our website will be made via this protocol. The client's browser must also support it.

Enabling HTTP/2 on Apache

If our WordPress server is running on Apache, HTTP/2 can be enabled using the mod_http2 module. First, check whether this module is available on our server. If not, you need to install it. Below is the command that can be used to enable the mod_http2 module:

sudo a2enmod http2

Then, add the following line to the Apache configuration file (.htaccess):

Protocols h2 http/1.1

Enabling HTTP/2 on the Nginx server

If our WordPress server is running on Nginx, HTTP/2 can be enabled by adding http2 to the listen directive in the Nginx server configuration. Below is an example configuration:

server { listen 443 ssl http2; listen [::]:443 ssl http2; ... }

WordPress plugins to enable HTTP/2 Server Push

If we want to use the HTTP/2 Server Push feature on our WordPress website, we can do it with the appropriate plugin.

HTTP/2 Server Push WordPress Plugin

One plugin that makes this possible is the HTTP/2 Server Push WordPress Plugin. This plugin automatically adds link headers to resources on our website, which allows you to "push" these resources into the client's browser cache.

Swift Performance Lite

Another plugin is Swift Performance Pro, which not only enables HTTP/2 Server Push, but also includes many other features to optimize WordPress performance.

LiteSpeed Cache

Yet another plugin is LiteSpeed Cache. This plugin offers many performance optimization features, including HTTP/2 Server Push, but only works on LiteSpeed servers.

To summarize, HTTP/2 is a powerful tool that can significantly speed up the performance of our WordPress website. However, to use it, we need to make sure our server and WordPress plugins support it.

Check out the offer of 1500+ Premium WordPress plugins and themes!