static file cluster

Liang Jin mywebadmin at
Thu May 10 02:29:05 MSD 2007

I have thought about Memcached. But you would not store the static
file in Memcached. Only the information about where the cached file is
located should be stored.

However, I am not seeing an option in Nginx Memcached module to fetch
just a key value and use that in a "if" statement.

For example:

Incoming request asks for /static/file1

And in the Memcached database, the file1 location (backend peer) can
be indicated by the key 'static_'+$memuri

So, in nginx, you can set $memcached_key to be  'static_'+$memuri

However, the fetched value of the key is not available for other uses,
unless " memcached_pass ".

Anyway, I have thought about one way to do this with nginx.  Use "  if
-f  filename" to check if the request file exists in the local file
system. If yes, go ahead and serve the file. If not, invoke a backend
script to fetch the file from original server, and store it in the
local cache. However, the problem is what program you can use to
stream the data to nginx while storing it to the hard drive. You do
not want to download twice, right? Anyway, an expiration scheme also
needs to be in place to prevent the cache from going too big.



On 5/9/07, Cliff Wells <cliff at> wrote:
> On Tue, 2007-05-08 at 11:40 -0700, Liang Jin wrote:
> > The problem is that I will need to find a caching solution that will
> > store the file in the local cache folder after serving the contents.
> > Secondly, I will need a way to talk to the peers if I have more
> > frontend caching servers.
> Memcached?
> Cliff

More information about the nginx mailing list