Nginx cache files by mime type using ngx_srcache module
n1xman
nginx-forum at nginx.us
Wed Jun 12 10:51:31 UTC 2013
Hi agentzh,
Thanks for the support and it is working :)
However, I have noticed every srcache_fetch GET /memc subrequest hits the
memcached even though srcache_store skipped content-type which is not
defined.
This will keep busy the memcached server and I think srcache_fetch GET
subrequest should not executed if srcache_store_skip triggered first. Or am
I missing something here...
map $upstream_http_content_type $no_store {
default 1;
~*html 0;
}
server {
..
location /memc {
internal;
set_unescape_uri $memc_key $arg_key;
set $memc_key $arg_key;
set $memc_exptime $arg_exptime;
memc_pass 127.0.0.1:11211;
}
location / {
srcache_response_cache_control off;
set_escape_uri $key $uri$args;
set $ttl_1d 60;
srcache_fetch GET /memc key=$key;
srcache_store PUT /memc key=$key&exptime=$ttl_1d;
srcache_store_statuses 200;
proxy_pass http://192.168.0.61:900;
srcache_store_skip $no_store;
}
..
}
Find the debug logs when firing following urls
curl -i http://192.168.0.160/index.html < served from the memcached
curl -i http://192.168.0.160/santa.jpg < not served from the memcached but
the request hits the memcached
error.log
http://pastebin.com/jbMm83qh
[root at localhost conf.d]# nginx -V
nginx version: nginx/1.4.1
built by gcc 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx
--with-http_ssl_module --with-http_realip_module --with-http_addition_module
--with-http_sub_module --with-http_dav_module --with-http_gunzip_module
--with-http_gzip_static_module --with-http_random_index_module
--with-http_secure_link_module --with-http_stub_status_module
--with-mail_ssl_module --with-file-aio --without-mail_smtp_module
--without-mail_imap_module --without-mail_pop3_module --with-debug
--with-http_spdy_module
--add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.4.1/contrib/ngx_devel_kit-master
--add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.4.1/contrib/echo-nginx-module-master
--add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.4.1/contrib/set-misc-nginx-module-master
--add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.4.1/contrib/srcache-nginx-module-master
--add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.4.1/contrib/nginx-sticky-module-1.1
--add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.4.1/contrib/nginx_upstream_check_module-master
--add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.4.1/contrib/memc-nginx-module-master
--add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.4.1/contrib/nginx_cross_origin_module-master
--with-cc-opt='-O2 -g'
Really appreciate your support here.
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,240023,240049#msg-240049
More information about the nginx
mailing list