# Controlling

**URL:** <https://www.ruby-forum.com/t/controlling/223882>\
**Category:** NGINX\
**Created:** [October 22, 2012, 11:32am UTC](https://www.ruby-forum.com/t/controlling/223882 "2012-10-22T11:32:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [October 22, 2012, 11:32am UTC](https://www.ruby-forum.com/t/controlling/223882/1 "2012-10-22T11:32:11Z")

</div>

With reference to:  
[http://nginx.org/en/docs/http/ngx\_http\_fastcgi\_module.html#fastcgi\_cache\_path](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](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:

> **[Controlling](https://forum.nginx.org/read.php?2,232079,232079#msg-232079)**
>
> 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...
