Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 




      :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

memcached integration idea + other ideas

Memcached integration as a caching mechanism


1. caching layer
if url + params or F(url,params) is in memcached return cached data w/o backend call F(x) - function such as crc32 / md5 / sha / ...

    location /dir {
         mem_cache on;  // activate cache check prior to backend query

2. Static data auto caching:
   cache files according to criteria and specified timeout.
Example: cache all gif / jpg ( /\.(jpg|gif)$/i ) files for 10 minutes

   location ~* ^.+\.(jpg|jpeg|gif)$ {
      mem_cache on;                 //  turn on caching (#1)
      mem_cache_ttl 600;            //  default cache time

3. Dynamic data caching:
   Cache files according to  X-cache header
     header("X-cache: $timeout");   // cache url call for given timeout

4. Internal server redirects
   header("X-redirect: $timeout");

   same as in Java Servlets forward.
   a.    NGINX -> BACKEND1
   b.    backend returns X-redirect and URL in  REDIR_URL
   c.    NGINX -> REDIR_URL

   maybe this already implemented

5. Redirect to "hash key"
   When page returns X-redirect-cache header:
Return page stored in memcached key (key = value of "X-redirect-cache" header)
   OR (if no page found)
   Internal redirect to  $no_key_url  and return content to caller
in case of redirect server should pass "key" to $no_key_url ( as a header or as a GET field )

   header("X-redirect-cache: $key $no_key_url")

   // guess what we want to show
   $page="index-".random_number( from => 1, to => 10)
   header("X-cache-key: $page /page-generator")


Copyright © Lexa Software, 1996-2009.