Memcached with nginx on rails

As promised in my last article i m posting the way to configure memcached with nginx. Nothing much to do again

Download memcached from you might also require a memcache lib available on install both of them and the memcached command will be available to you

just type in this on the terminal

memcached -p 11211

Thats memcache is on. Just few more changes in the nginx.conf file and you r ready to zoom your rails app

you just need to write this

location /dynamic_request {   # append an extenstion for proper MIME type detection
  if ($args ~* format=json) { rewrite ^/dynamic_request/?(.*)$ /dynamic_request.js$1 break; }
   if ($args ~* format=xml)  { rewrite ^/dynamic_request/?(.*)$ /dynamic_request.xml$1 break; }


        error_page 404 = @dynamic_request;


Also you might require to set the uri so do this

    set  $memcached_key  $uri;

Ok thats done no restart nginx service and your memcache + mongrel cluster with gzip on will be running and ur rails app will be zoooooooooooooming


Be Sociable, Share!