Welcome! Log In Create A New Profile

Advanced

Controlling

October 22, 2012 05:31AM
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.

--
Rahul Bansal
EasyEngine - https://github.com/rtCamp/easyengine
SubjectAuthorPosted

Controlling

rahul286October 22, 2012 05:31AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 97
Record Number of Users: 7 on March 06, 2014
Record Number of Guests: 184 on July 08, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready