ngx_memc v0.06: new directive memc_flags_to_last_modified
agentzh
agentzh at gmail.com
Fri Jan 29 10:26:03 MSK 2010
Hi, folks!
I'm pleased to announce the v0.06 release of the ngx_memc module:
http://wiki.nginx.org/NginxHttpMemcModule
This release has the highlight of a new directive named
"memc_flags_to_last_modified".
If this directive is turned on, then for memcached get operations,
ngx_memc will read the memcached flags as epoch seconds and set it as
the value of the Last-Modified header.
For conditional GET requests, it will signal nginx's
not_modified_filter module to return the "304 Not Modified" response
to save bandwidth.
Here's a small sample config that I've tested with ngx_memc v0.06:
# read the memcached flags into the Last-Modified header
# to respond 304 to conditional GET
location /memc {
set $memc_key $arg_key;
memc_pass 127.0.0.1:11984;
memc_flags_to_last_modified on;
}
My GET request sets the following header:
If-Modified-Since: Thu, 28 Jan 2010 12:09:23 GMT
And the key stored in memcached has the flags 1264680563. Then we get
$ curl -H 'If-Modified-Since: Thu, 28 Jan 2010 12:09:23 GMT' \
-I 'http://localhost:1984/memc?key=foo'
HTTP/1.1 304 Not Modified
Server: nginx/0.8.32
Date: Fri, 29 Jan 2010 07:10:52 GMT
Last-Modified: Thu, 28 Jan 2010 12:09:23 GMT
Connection: keep-alive
How about setting the flag with ngx_memc too? Well, I'm going to
implement the $echo_time and $echo_http_time variables in our ngx_echo
module so that we can have
set $memc_flags $echo_time;
add_header Last-Modified $echo_http_time;
for memcached storage operations set/add/etc. That is, $echo_time will
return the epoch seconds while $echo_http_time returns the textual
representation in the HTTP date format. Patches welcome! Volunteers
welcome!
Have fun!
-agentzh
More information about the nginx
mailing list