emptygif
언어: 한국어

모든 언어 및 프레임워크

OpenResty (Lua) Lua

/pixel.gif 요청에 빈 GIF로 응답하는 OpenResty (Lua)용 Lua 스니펫입니다. GIF는 시작할 때 한 번만 디코딩합니다.

OpenResty (Lua) Lua

파일
nginx.conf
실행
openresty -s reload
http {
    init_by_lua_block {
        -- decoded once, when the master process loads the config
        PIXEL_GIF = ngx.decode_base64("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
    }

    server {
        listen 8080;

        location = /pixel.gif {
            content_by_lua_block {
                ngx.header["Content-Type"] = "image/gif"
                ngx.header["Content-Length"] = #PIXEL_GIF
                ngx.header["Cache-Control"] = "no-store"
                ngx.print(PIXEL_GIF)
            }
        }
    }
}

이 스니펫은 실행해 보고, 반환된 바이트를 비교했습니다.

확인

curl -sI http://localhost:8080/pixel.gif

공식 사이트: OpenResty (Lua)