Proxy cache doesn't work in regex location?

Jeff Mitchell jeff at
Fri Jan 28 07:57:24 MSK 2011

On 01/27/2011 11:12 PM, Jeff Mitchell wrote:
> Hello,
> I have the following two blocks:
>     location ~* \.atom$ {
>         proxy_pass http://thin_projects_cluster;
>         proxy_cache projects;
>         proxy_cache_valid 200 10m;
>         proxy_cache_use_stale off;
>         #return 404;
>     }
>     location / {
>         proxy_pass http://thin_projects_cluster;
>         #proxy_cache projects;
>         #proxy_cache_valid 200 10m;
>         #proxy_cache_use_stale off;
>     }
> If I comment out everything in the top block and uncomment the "return
> 404" then I get 404 errors when accessing URLs ending in .atom, so I
> know that that regex is successfully matching some of my content.
> That said, the problem I have is that the cache is not working for the
> top block, but if I comment the cache statements in the top block and
> uncomment the cache statements in the bottom block, the cache starts
> populating as expected. I can't figure out what the difference is.
> Does anyone know what might be going on?

In what I'm guessing is a similar scenario, I also didn't get caching
working when using try_files to send to a location like @cluster, and
then having those proxy_cache directives at location @cluster.

Does proxy_cache only work for explicitly defined locations?


More information about the nginx mailing list