34

Is there a command or a service that will tell me whether my websites are being served over HTTP or HTTP/2.

I found this tool: HTTP/2 Test | A simple HTTP/2.0 test tool, but it only tells me whether my website supports HTTP/2, but not whether it is already using HTTP/2.

These is also this Chrome Extension: HTTP/2 and SPDY indicator, which tells me that HTTP/2 is already enabled on my site, but as far as I know my version of Apache doesn't even support it.

Is there any way to know for sure? Thanks!

Vadim
  • 1,916
  • 2
  • 19
  • 39
  • `mod_http2` is available in version 2.4.17 of Apache and later. You have to use the latest OpenSSL 1.0.2 (better the latest OpenSSL 1.0.2h and very soon 1.1.0). You will hind more details [here](https://icing.github.io/mod_h2/howto.html). Why you see a problem to update your web server to the latest 2.4.20 version? Do you expect some compatibility problems in your software? You can use IE developer Tools or Chrome developer tools (one just make "Protocol" column visible), clear the cache (important !!!) and to see HTTP2 or h2 in the Network trace. You can just test the same first on cdnjs.com – Oleg Apr 29 '16 at 14:45
  • Thanks, @Oleg. I've looked into `mod_http2`, and I wanted to install it, but I run CentOS, and its latest pre-packaged version of Apache is 2.4.6 (which, like you said, doesn't support `mod_http2`) . I think the only way to upgrade to 2.4.17 is to compile Apache from scratch, but I am not sure that I want to do that. I may just have to wait until CentOS rolls out an update. – Vadim Apr 29 '16 at 15:47
  • You are welcome! I don't use CentOS, but it seems that one should really compile the sources: see [here](https://httpd.apache.org/docs/2.4/platform/rpm.html). Probably it's easy. I have no experience. In any way HTTP/2 will speed up your site in about 30%. Moreover you will be able to use JavaScript modules without merging, because loading of many small files is very quickly under HTTP/2. You can configure web server to load the most small file (jQuery etc) with 1 year long cache. The user will typically load such files only once. I mean HTTP/2 is really important feature which I recommend you – Oleg Apr 29 '16 at 17:37
  • I completely agree, @Oleg. I am also very excited about HTTP/2 and cannot wait to start using it. From what I've read online, it seems to be a substantial improvement over its predecessor. Thanks for the link! Maybe I'll succeed in compiling the newer Apache using the instructions in the link. :) – Vadim Apr 29 '16 at 19:39
  • Here's my post on how to install from source on centos: https://www.tunetheweb.com/performance/http2/ if you're interested. – Barry Pollard Apr 29 '16 at 20:28
  • Note: apache prefork module does not support http2! – GChuf Mar 16 '20 at 14:36

4 Answers4

42

Apache doesn't have to support it. The Chrome extension reads the HTTP headers to determine that.

Another method is simply to look at the network tab > headers > response headers > view source in Chrome or Firefox. There the headers can be seen. It should read "HTTP/2" or some sort I can't recall right now.

Easiest: You can use curl -I <your site> which will put the HTTP response as the first line.

HTTP/2.0 200
server:nginx
date:Fri, 29 Apr 2016 14:31:40 GMT
content-type:text/html; charset=utf-8
content-length:7629
last-modified:Thu, 07 Apr 2016 02:41:08 GMT
....
Rob
  • 14,746
  • 28
  • 47
  • 65
35

Here's another method that may be easier, if you don't have ready access to command-line and cURL, or you're navigating several layers of CDN (e.g. if your HTTP/2 is being provided by a provider like CloudFlare).

  1. Open Chrome Dev Tools (Ctrl-Shift-I)
  2. Open the Network tab
  3. If your page has already loaded, you may need to refresh (Ctrl-R)
  4. Right-click on the header row of the request list (the row labelled: Name, Method, Status, etc.)
  5. Select Protocol from the context menu.
  6. You may need to refresh again (Ctrl-R), and you will see all the protocols being used.

Chrome Dev Tools Screenshot.

If you see h2, then congratulations! Your website is being served over HTTP/2.

haz
  • 1,549
  • 15
  • 20
  • 1
    Initially I didn't got the details , Later only understood that , 'All' Need to be selected (Adjacent to Hide Data URLs, above picture ) – Arun Oct 19 '20 at 06:57
3

For people using Nginx, you can view the access log which is usually located at /var/log/nginx/access.log and look for lines like

167.220.232.9 - - [12/Feb/2018:15:09:04 +0800] "GET / HTTP/2.0" 200 2546 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"
Michael Ma
  • 872
  • 8
  • 20
2

You can also try --http2 or --http2-prior-knowledge. These will force the webiste to use HTTP/2.0:

From the curl manual:

--http2-prior-knowledge
              (HTTP) Tells curl to issue its non-TLS HTTP requests using HTTP/2 without HTTP/1.1 Upgrade.  It  requires
              prior  knowledge  that  the server supports HTTP/2 straight away. HTTPS requests will still do HTTP/2 the
              standard way with negotiated protocol version in the TLS handshake.

              --http2-prior-knowledge requires that the underlying libcurl was built to  support  HTTP/2.  This  option
              overrides --http1.1 and -0, --http1.0 and --http2. Added in 7.49.0.

--http2
              (HTTP) Tells curl to use HTTP version 2.

              See also --no-alpn. --http2 requires that the underlying libcurl was built to support HTTP/2. This option
              overrides --http1.1 and -0, --http1.0 and --http2-prior-knowledge. Added in 7.33.0.
prosti
  • 42,291
  • 14
  • 186
  • 151