Custom response codes and content-types for memcache module
Spil Games
lists at ruby-forum.com
Mon Sep 8 16:34:09 MSD 2008
Hi,
I've just completed the "final" version of this patch. It allows both
custom headers and custom response codes to be returned from memcached.
There is one restriction though: it is not possible to use an
'error_page' directive on the outcome of the memcached module. This was
neccessary to be able to distinguish between a 404 response successfully
served from memcached and a 404 response generated because no cache item
could be found.
This behaviour is triggered on a successfull hit from memcached:
/* disallow interception of error pages */
u->conf->intercept_404 = 0;
u->conf->intercept_errors = 0;
r->error_page = 1;
Above code disables both interception of errors and custom error pages.
It has been tested using the following Nginx config:
default_type text/html;
error_page 404 = /dyn$request_uri;
if ($request_method ~* "^(GET|HEAD)$") {
set $memcached_key $server_name$request_uri;
memcached_pass memcached_backend;
}
The 'error_page 404' will only be triggered when the memcached module
returns a 404 because of a missing cache item, NOT when a 404 response
is served from the cache.
Feedback highly appreciated. This is my first 'hack job' on Nginx, but I
hope this will be good enough to be included into the official
distribution of Nginx. Igor?
Regards,
Matthijs
Attachments:
http://www.ruby-forum.com/attachment/2655/nginx-0.6.32-memcache.final.patch
--
Posted via http://www.ruby-forum.com/.
More information about the nginx
mailing list