Skip to content

Instantly share code, notes, and snippets.

@allieus
Last active December 18, 2015 11:59
Show Gist options
  • Save allieus/5779804 to your computer and use it in GitHub Desktop.
Save allieus/5779804 to your computer and use it in GitHub Desktop.
openresty 1.2.8.6 에서 srcache + uwsgi
# django 단에서 데이터 변경 시에 캐싱된 데이터를 memcache 을 통해 직접 삭제하고 있습니다.
upstream memcached {
server 127.0.0.1:11211;
}
server {
memc_connect_timeout 100ms;
memc_send_timeout 100ms;
memc_read_timeout 100ms;
srcache_ignore_content_encoding on;
srcache_methods GET HEAD;
srcache_store_statuses 200 301 302 304 404;
location = /memc {
internal;
set_unescape_uri $memc_key :1:$arg_key; # django 에서는 캐싱키에 ":1:" prefix 을 붙입니다.
set $memc_exptime 3600;
memc_pass memcached;
}
location / {
proxy_ignore_client_abort on;
set_by_lua $no_cache '
if string.match(ngx.var.uri, "caching_url") then
return 0;
end
return 1;
';
srcache_fetch GET /memc key=$uri;
srcache_store PUT /memc key=$uri;
srcache_fetch_skip $no_cache;
srcache_store_skip $no_cache;
include uwsgi_params;
uwsgi_pass 127.0.0.1:8080;
uwsgi_param UWSGI_SCHEME $scheme;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment