Controlling
rahul286
nginx-forum at nginx.us
Mon Oct 22 09:31:24 UTC 2012
With reference to:
http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_cache_path
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_module.html#fastcgi_cache_key
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
More information about the nginx
mailing list