I prefer to do a more complete cache header, in addition to some more file extensions. The '?' prefix is a 'non-capturing' mark, nginx won't create a $1. It helps to reduce unnecessary load.
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
}
Nearly all of the "distributed" part of memcached is handled on the client side.
If you have multiple memcached servers defined in your config (I see the php tag on your post, so I'm guessing you're using pecl/memcache, but I think the syntax is similar for pecl/memcached)
<?php
$mc = new Memcache()
$mc->addServer('node1', 11211);
$mc->addServer('node2', 11211);
$mc->addServer('node3', 11211);
?>
the client will determine which server to put the data in using a hash of the key. There's an option of the addServer method (retry_interval = -1) where if a memcached server goes down, your PHP will not continue to try it.
There is some information about how you can do "replication" in Memcache, but from my experience, it's not really worth the effort or the "wasted" memory (you'd have to store all caches on all servers, where if you just use the built-in distribution mechanism, it'll just have to be stored on one. Obviously, if one of your servers die, you're going to get cache misses until that data is stored on another server, but you shouldn't be using Memcache as a persistent store, anyway). The Memcache client protocol is pretty smart. ;)
Original link to https://blogs.oracle.com/trond/entry/replicate_your_keys_to_multiple removed as it no longer exists.
Best Answer
The Nginx HttpMemcachedModule allows the use of Memcached as storage, but does not store HTTP headers with data - all pages served via Memcached storage have the default
Content-Type
and do not honorLast-Modified
/If-Modified-Since
headers and proper304 Not Modified
header.The Enhanced Nginx Memached Module is based on the standard module and has additional features which include storing HTTP headers together with data honoring the required HTTP headers.