rahul286 nginx-forum at
Mon Oct 22 09:31:24 UTC 2012

With reference to:

file names in a cache looks like this:


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




With reference to

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

If cache path become:


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

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

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

Posted at Nginx Forum:,232079,232079#msg-232079

More information about the nginx mailing list