Skip to content

This is an experimental nginx module that sending 103 early hints.

Notifications You must be signed in to change notification settings

nginx-modules/ngx_http_early_hints

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ngx_http_early_hints

This is an experimental nginx module that sending 103 early hints before sending content(NGX_HTTP_ACCESS_PHASE).

103 is defined by An HTTP Status Code for Indicating Hints, and This module implements the draft-00.

Getting started

There is the configuration below.

location /103.html {
    add_early_header "Link" "</main.css>;rel=preload";
    add_early_header "Link" "</main.js>;rel=preload";
    add_early_header "hoge" "hogehoge";
}

There is the response below.

vagrant@vagrant:~$ curl --dump-header - localhost/103.html
HTTP/1.1 103 Early Hints
Link: </main.css>;rel=preload
Link: </main.js>;rel=preload
hoge: hogehoge

HTTP/1.1 200 OK
Server: nginx/1.11.6
Date: Sun, 11 Dec 2016 10:27:20 GMT
Content-Type: text/html
Content-Length: 22
Accept-Ranges: bytes

This is main contents

$early_hints variable means sending 103 status code and Early Hints headers.

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  'early_hints:$early_hints';
127.0.0.1 - - [08/Dec/2016:16:52:11 +0000] "GET /103.html HTTP/1.1" early_hints:1
127.0.0.1 - - [08/Dec/2016:16:52:07 +0000] "GET / HTTP/1.1" early_hints:0

Demo URL

https://asnokaze.com/103.html

Builid

Get a Nginx code

vagrant@vagrant:~$ git clone https://github.com/flano-yuki/ngx_http_early_hints.git
vagrant@vagrant:~$ wget https://nginx.org/download/nginx-1.11.6.tar.gz
vagrant@vagrant:~$ tar zxvf ./nginx-1.11.6.tar.gz
vagrant@vagrant:~$ cd ./nginx-1.11.6/
vagrant@vagrant:~$ ./configure --add-module=/home/vagrant/ngx_http_early_hints/
vagrant@vagrant:~$ make

TODO

  • More strict error handling
  • Support http2
  • Add test

About

This is an experimental nginx module that sending 103 early hints.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 81.9%
  • Perl 18.1%