Caching fastcgi url

Francis Daly francis at
Tue Jun 23 22:07:49 UTC 2015

On Tue, Jun 23, 2015 at 04:19:48PM -0400, CJ Ess wrote:

Hi there,

> - Would I need to define a separate location stanza for the URL I want to
> cache and duplicate all of the fastcgi configuration that is normally
> required? Or is there a way to indicate that of all the fastcgi requests
> only the one matching /xyz is to be cached?

fastcgi caching is handled by the fastcgi_cache directive, documented

It is set per-location.

See also directives like fastcgi_cache_bypass and fastcgi_no_cache.

It is probably simplest to have on exact-match location for this url
and not worry about the no_cache side of things.

"all the configuration that is normally required" is typically four lines
-- one "include" of common stuff; one or two extra fastcgi_param values,
and a fastcgi_pass.

> - If multiple request for the same URL arrive at around the same time, and
> the cache is stale, they will all wait on the one request that is
> refreshing the cache, correct? So I should only see one request for the
> cached location per worker per minute on the backend?

If that's what you want, you can probably configure it.

> - Since my one URI is fairly small, can I indicate that no file backing is
> needed?

I don't think so. But you can have fastcgi_cache_path set to a ramdisk,
I think.

Francis Daly        francis at

More information about the nginx mailing list