NGINX $request_uri vs $uri

后端 未结 2 1263
囚心锁ツ
囚心锁ツ 2021-01-31 08:03

How do you determine when to use $request_uri vs $uri?

According to NGINX documentation, $request_uri is the original request (for

2条回答
  •  轮回少年
    2021-01-31 08:39

    Another difference about $uri and $request_uri in proxy_cache_key is $request_uri will include anchor tags part, but $uri$is_args$args will ignore it

    Do a curl operation : curl -I static.io/hello.htm?id=1#/favor/goods :

    proxy_cache_key $scheme://$host$uri$is_args$args; => Cache KEY: http://static.io/hello.htm?id=1
    proxy_cache_key $scheme://$host$request_uri; => Cache KEY: http://static.io/hello.htm?id=1#/favor/goods
    

    Nginx Document: http://nginx.org/en/docs/http/ngx_http_core_module.html#var_request_uri

    • $request_uri : full original request URI (with arguments)
    • $uri: current URI in request, normalized The value of $uri may change during request processing, e.g. when doing internal redirects, or when using index files.

    Proxy Cache key: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_key

提交回复
热议问题