try_files, POST, and redirecting requests to Passenger

Jason R. lists at
Wed Jan 9 19:39:33 UTC 2013

"António P. P. Almeida" <appa at> wrote in post #1091605:
> On 9 Jan 2013 15h22 CET, lists at wrote:
>>> try_files /maintenance.html @passenger;
>>> }
>> I never knew about the map directive, that's quite interesting. One
>> question though, will this make sure that a POST that hits the
>> error_page 418 stays a POST when it goes through the @idempotent
>> location?
> Perhaps I misunderstood. The way it is configured above is such that
> the @idempotent location will only be used for GET and HEAD requests.
> All other requests are handled by the / location using the lenghty
> try_files.
> I thought that was your desired config.
>> Thanks for the info!
> You're welcome.
> --- appa

Sorry if I mispoke then, what I want is the exact opposte because POST 
should never hit a cache file.

We ended up going a slightly different route in that we hack the cache 
file location according to the request type (we have $cache_host because 
there's some other processing we do, not relevant here):

  # Set cache_path to a non-existant directory so try_files fails if we 
  # serve the request from the cache.
  set $cache_path "no-cache";
  set $cache_host $host;

  if ($request_method ~* ^(GET|HEAD)$) {
    set $cache_path "cache";


This way there's no possible way a valid file is found when POST-ing. 
This was the simplest solution we could come up with at this time.

Thanks for everyone's help.


Posted via

More information about the nginx mailing list