Proxy cache doesn't work in regex location?

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?

Thanks,
Jeff

On 01/27/2011 11:12 PM, Jeff M. wrote:

}

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?

Thanks,
Jeff

You ever get a solution Jeff?

I’ve come accross the same problem when trying to cache anything with a
.html extension - proxy_cache not liking the location / regex

:slight_smile:

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,170307,189430#msg-189430

Hello!

On Fri, Apr 08, 2011 at 10:32:10AM -0400, andrewsuk wrote:

You ever get a solution Jeff?

I’ve come accross the same problem when trying to cache anything with a
.html extension - proxy_cache not liking the location / regex

:slight_smile:

The solution is to carefully check headers returned by backend.

The following may/will disable cache unless ignored with
proxy_ignore_headers directive: X-Accel-Expires, Expires,
Cache-Control, Set-Cookie.

Maxim D.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs