Nginx and If-Modified-Since/If-None-Match headers

nginxrewrite

Anyone know how to rewrite this apache rule for Nginx?


RewriteRule .* - [E=HTTP_IF_MODIFIED_SINCE:%{HTTP:If-Modified-Since}]

RewriteRule .* - [E=HTTP_IF_NONE_MATCH:%{HTTP:If-None-Match}]

Thanks

Best Answer

As I see, you are trying to pass the header HTTP_IF_NONE_MATCH and HTTP_IF_MODIFIED_SINCE from nginx to fastcgi application..

Try it adding this lines in your nginx.conf file:

fastcgi_param HTTP_IF_NONE_MATCH $http_if_none_match;
fastcgi_param HTTP_IF_MODIFIED_SINCE $http_if_modified_since;

After that, if you are using, for example PHP, you can get the values of the vars with either of these 2 examples:

$_SERVER['HTTP_IF_NONE_MATCH']
$_SERVER['HTTP_IF_MODIFIED_SINCE']