From 6e299d8972a76bdddc703c58a98c724ff8e67746 Mon Sep 17 00:00:00 2001 From: Sven Hoexter Date: Sun, 2 Dec 2018 11:15:02 +0100 Subject: [PATCH] nginx config to set cache-control response header based on a cc request header Looks out for the request HTTP header "cc", if it's set it takes the header values verbatim and uses them as the value for a "cache-control" response header. Allows for a dynamic evaluation of a CDN caching configuration. --- nginx/set_cache_control.conf | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 nginx/set_cache_control.conf diff --git a/nginx/set_cache_control.conf b/nginx/set_cache_control.conf new file mode 100644 index 0000000..a99c1fe --- /dev/null +++ b/nginx/set_cache_control.conf @@ -0,0 +1,12 @@ +location /cc { + default_type 'text/plain'; + content_by_lua_block { + local cc=ngx.req.get_headers()["cc"] + if cc ~= nil then + ngx.header["cache-control"]=cc + ngx.say(cc) + else + ngx.say("moep - no cc header found") + end + } +} \ No newline at end of file -- 2.39.2