diff --git a/README.markdown b/README.markdown index 9ff1632..19ba5ea 100644 --- a/README.markdown +++ b/README.markdown @@ -15,6 +15,7 @@ This module is based on the standard [Nginx Memcached module](http://wiki.nginx. * Get memcached'stats, via HTTP request to nginx * Manage key namespaces, for partial memcached flush * Reply `304 Not Modified` for request with `If-Modified-Since` headers and content with `Last-Modified` in cache +* Reply `304 Not Modified` for request with `If-None-Match` headers and content with `ETag` in cache * Set custom HTTP code to send redirect You can find some explanations qbout why this module has been created in this [blog post](http://blog.octo.com/en/http-caching-with-nginx-and-memcached/). @@ -225,7 +226,9 @@ You can flush a namespace (in reality, it only increment the key prefix) with a 304 Not Modified === -For request with HTTP Header `If-Modified-Since`, and associated resource in memcached with HTTP Headers `Last-Modified`, the module will send a 304 Not Modified if resource has not been modified, and if Nginx [configuration](http://wiki.nginx.org/HttpCoreModule#if_modified_since) allows this behaviour. +For request with HTTP Header `If-Modified-Since`, and associated resource in memcached with HTTP Header `Last-Modified`, the module will send a 304 Not Modified if resource has not been modified, and if Nginx [configuration](http://wiki.nginx.org/HttpCoreModule#if_modified_since) allows this behaviour. + +For request with HTTP Header `If-None-Match`, and associated resource in memcached with HTTP Header `ETag`, the module will send a 304 Not Modified if resource has not been modified. License === diff --git a/ngx_http_enhanced_memcached_module.c b/ngx_http_enhanced_memcached_module.c index 780b5d7..ed46be8 100644 --- a/ngx_http_enhanced_memcached_module.c +++ b/ngx_http_enhanced_memcached_module.c @@ -1240,7 +1240,7 @@ ngx_http_enhanced_memcached_process_request_get(ngx_http_request_t *r) return NGX_ERROR; } - if (h->key.len == sizeof("Etag") - 1 && ngx_strncmp(h->key.data, "Etag", h->key.len) == 0) { + if (h->key.len == sizeof("ETag") - 1 && ngx_strncmp(h->key.data, "ETag", h->key.len) == 0) { etag = h; } diff --git a/tests/ns_test.rb b/tests/ns_test.rb index 269c1e6..7b7e536 100644 --- a/tests/ns_test.rb +++ b/tests/ns_test.rb @@ -487,19 +487,19 @@ def test_last_modified_png end def test_if_none_match - put '/toto', "EXTRACT_HEADERS\r\nMyHeader: tata\r\nEtag: foo\r\n\r\nthis content", @put_domain + put '/toto', "EXTRACT_HEADERS\r\nMyHeader: tata\r\nETag: foo\r\n\r\nthis content", @put_domain assert_stored get '/toto', @std_domain assert_last_response "200", "application/octet-stream", 'this content' - assert_equal "foo", @resp['Etag'] + assert_equal "foo", @resp['ETag'] assert_equal "tata", @resp["MyHeader"] get '/toto', @std_domain, {"If-None-Match" => "bar"} assert_last_response "200", "application/octet-stream", 'this content' - assert_equal "foo", @resp['Etag'] + assert_equal "foo", @resp['ETag'] assert_equal "tata", @resp["MyHeader"] get '/toto', @std_domain, {"If-None-Match" => "foo"} assert_last_response_code "304" - assert_equal "foo", @resp['Etag'] + assert_equal "foo", @resp['ETag'] assert_equal "tata", @resp["MyHeader"] assert_nil @resp["Content-Type"] assert_nil @resp["Content-Length"] @@ -508,19 +508,19 @@ def test_if_none_match def test_if_none_match_png png = load_bin_file('show_48.png') - put '/png', "EXTRACT_HEADERS\r\nMyHeader: tata\r\nEtag: foo\r\nContent-Type: image/png\r\n\r\n" + png, @put_domain + put '/png', "EXTRACT_HEADERS\r\nMyHeader: tata\r\nETag: foo\r\nContent-Type: image/png\r\n\r\n" + png, @put_domain assert_stored get '/png', @std_domain assert_last_response "200", "image/png", png - assert_equal "foo", @resp['Etag'] + assert_equal "foo", @resp['ETag'] assert_equal "tata", @resp["MyHeader"] get '/png', @std_domain, {"If-None-Match" => "bar"} assert_last_response "200", "image/png", png - assert_equal "foo", @resp['Etag'] + assert_equal "foo", @resp['ETag'] assert_equal "tata", @resp["MyHeader"] get '/png', @std_domain, {"If-None-Match" => "foo"} assert_last_response_code "304" - assert_equal "foo", @resp['Etag'] + assert_equal "foo", @resp['ETag'] assert_equal "tata", @resp["MyHeader"] assert_nil @resp["Content-Type"] assert_nil @resp["Content-Length"]