Bug in memcached module?

Hi,

I have the following config (just a snippet):

set $memcached_key $uri;
default_type “text/html; charset=utf-8”;
error_page 404 @fallback;

The problem is, that whenever memcached does not find the value in
memory, I get a 404 status code.
My fallback is an Apache HTTP server which handles the request via
mod_php. In case of a 404 the request is forwarded to Apache/PHP, PHP
updates memcached, and the result is returned via nginx.
BUT the status code header is not correct. Even if I manually set a 200
OK header in PHP, a 404 header is returned by nginx.
If the the URI is in memcached already, a normal 200 OK header is
returned.

So - to me this seems like a bug?

Hope someone can help :slight_smile:

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

Maybe I should add, that the returned HTML is always correct, whether
memcached finds it in memory or not…it’s only the status code header
that is wrong.

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

Hello!

On Wed, Oct 21, 2009 at 05:27:11AM -0400, mastercan wrote:

Hi,

I have the following config (just a snippet):

set $memcached_key $uri;
default_type “text/html; charset=utf-8”;
error_page 404 @fallback;

  • error_page 404 @fallback;
  • error_page 404 = @fallback;

The problem is, that whenever memcached does not find the value in memory, I get a 404 status code.
My fallback is an Apache HTTP server which handles the request via mod_php. In case of a 404 the request is forwarded to Apache/PHP, PHP updates memcached, and the result is returned via nginx.
BUT the status code header is not correct. Even if I manually set a 200 OK header in PHP, a 404 header is returned by nginx.
If the the URI is in memcached already, a normal 200 OK header is returned.

So - to me this seems like a bug?

Yes, in your config.

And I checked wiki - it seems to have incorrect description for
error_page. I’ve reverted erroneous change, it should now be fine
now. Feel free to see for more details:

http://wiki.nginx.org/NginxHttpCoreModule#error_page

Maxim D.

Maxim D. Wrote:

  • error_page 404 @fallback;
  • error_page 404 = @fallback;

I guess this option with the = sign was added in one of the latest
development versions?
I’m using 0.7.62 (stable), where this is not recognized.

If it’s “safe” to switch to the development version, I could try that…

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

On Wed, Oct 21, 2009 at 07:44:38AM -0400, mastercan wrote:

Maxim D. Wrote:

  • error_page 404 @fallback;
  • error_page 404 = @fallback;

I guess this option with the = sign was added in one of the latest development versions?

No:

Changes with nginx 0.2.6 05 Oct
2005

*) Feature: the "error_page" directive supports redirects and allows
   more flexible to change an error code.

I’m using 0.7.62 (stable), where this is not recognized.

If it’s “safe” to switch to the development version, I could try that…

Yes, it’s safe enough: I try to keep it stable.

Igor S. Wrote:

I guess this option with the = sign was added in
one of the latest development versions?

No:

Oh, you’re right. The = sign is working under my version too, great.
I’m using
“error_page 404 = @fallback;”
now.

Thank you a lot for your support. Now the status code is always 200, as
it should be.

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

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