agentzh/srcache-nginx-module — Issue #12: Help with configuration of specific folder
Author: ricardovf
Created: 2012-01-11 19:24:01+00:00
State: open

Hi!

As i mentioned earlier im using srcache to serve assets like css/js/img.

My application does the mapping and generates URLs like:

http://frontdoor.ricardo/gimme/a04da9f9fd/pkg/css/index.css
http://frontdoor.ricardo/gimme/e82d990d14/js/backbone.js

So im trying to set srcache to just this folder: /gimme

Here is my config:

upstream memcached {
server 127.0.0.1:11211;
#keepalive 1024 single;
}

# frontdoor
server {
server_name frontdoor.*;

#	memc_connect_timeout 100ms;

root /Users/ricardo/Sites/frontdoor/www;

fastcgi_read_timeout 3600;

location = /memc {
internal;

memc_connect_timeout 250ms;
memc_send_timeout 250ms;
memc_read_timeout 250ms;

set $memc_key $query_string;
set $memc_exptime 0; # never expires

memc_pass memcached;
}

location / {
try_files $uri /index.php$is_args$args;
}

location /gimme {
set $key $http_host$request_uri;
srcache_fetch GET /memc $key;
srcache_store PUT /memc $key;
srcache_store_statuses 200 301 302 304 404;

try_files $uri /index.php$is_args$args;
}

location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass localhost:9000;
}
}

This way it does not write to memcached and its a miss everytime. If i move the srcache stuff to inside the location ~ \.php$ it will work, but i do not want the overhead of lookup in requests outside the /gimme folder.

Can you help me to do it the best way possible?

Thx