Forum: NGINX Controlling

Posted by rahul286 (Guest)
on 2012-10-22 11:32
(Received via mailing list)
With reference to:
http://nginx.org/en/docs/http/ngx_http_fastcgi_mod...

file names in a cache looks like this:

/data/nginx/cache/c/29/b7f54b2df7773722d382f4809d65029c

Is there any way to use different scheme for this, for example:

/data/nginx/cache/$http_host/$request_uri/

===

Reason:

With reference to
http://nginx.org/en/docs/http/ngx_http_fastcgi_mod...

For fastcgi_cache_key "$scheme$request_method$host$request_uri";

If cache path become:

/data/nginx/cache/$scheme/$request_method/$host/$request_uri

Then in location / block I can have something like:

location / {
    try_files 
/data/nginx/cache/$scheme/$request_method/$host/$request_uri
$uri $uri/ /index.php?$args;
  }

==

I think if try_files can "hit" cached location like above, it will be
faster.

As of now for a cached page, a request reaches fastcgi location block 
(not
fastcgI backend/upstream handler - just another location handler/another
internal rewrite).

In some tests, I found nginx's fastcgi_cache was taking slightly more 
time
to return a cached page. Difference was too small and I was testing 
against
only 1 URL.
I think nginx's way will perform better when lookup will be done among 
1000s
of cached pages.

==

Another reason for some control over fastcgi_cache_path is to have
$http_host prefix storage. As of now when clearing cache we need to wipe 
it
out completely. May be with $http_host in fastcgi_cache_path we will be 
able
to clear for a single-domain.

Something like:  fastcgi_cache_path /data/nginx/cache/$http_host 
levels=1:2
keys_zone=one:10m;

Not sure, if above works and creates non-existent directory 
automatically.

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,232079,232079#msg-232079
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.