Created
November 19, 2012 17:46
-
-
Save mtourne/4112241 to your computer and use it in GitHub Desktop.
Use Alternate-Protocol header to advertise SPDY to clients not using it already.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- the nginx variable $http_x_spdy_protocol contains the value for X-SPDY-Protocol | |
local SPDY_REQ_HEADER_VAR='http_x_spdy_protocol' | |
local ALTERNATE_HEADER='Alternate-Protocol' | |
local ALTERNATE_VALUE='443:npn-spdy/2' | |
local function is_spdy_on() | |
local spdy_version = tonumber(ngx.var[SPDY_REQ_HEADER_VAR]) or 0 | |
ngx.log(ngx.DEBUG, 'SPDY Version: ', spdy_version) | |
return spdy_version ~= 0 | |
end | |
-- Use Alternate-Protocol header to advertise SPDY | |
function advertise() | |
if not is_spdy_on() then | |
ngx.log(ngx.DEBUG, 'Advertising SPDY') | |
ngx.header[ALTERNATE_HEADER] = ALTERNATE_VALUE | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment