2

2.1, i am also using the amazon elastic cache service (its a memcached server)

Nginx has a clever feature that uses memcached for common get request, but if is a post request dont use memcached, is anyway to disable this feature?

Here is my configuration;

location /{
    set_md5  $memcached_key "http://$server_name$uri";
    memcached_pass cacheviews.bsd7na.0001.use1.cache.amazonaws.com:11211;
    default_type text/html;
    add_header Content-Encoding gzip;
    error_page 405 404 = @fallback;
}

location @fallback{
    internal;
    gzip_types text/css text/plain application/atom+xml application/x-javascript;
    gzip_vary on;
    #  stuff to do a normal render of the page
}
2
  • Did you have any luck with this? I'm running into the same problem with 405 errors on post requests
    – Kevin
    Jun 26, 2012 at 23:10
  • I couldn solve it using nginx rewrite... i have to add some code to the app.
    – Tim
    Jun 27, 2012 at 2:59

1 Answer 1

2

When you get POST request, it is supposed to change some objects in your backend's storage (database), which depends on the logic of your application. So, NGINX just has no idea about what actually must be done in your application and simply does not try to cache any POST request, redirecting them directly to your backend.

Meanwhile, GET requests are supposed only to read data, without any writing - so, it can be easily cached, because every time the result of reading would be the same.

2
  • 1
    You are right, im gone accept the answer because its okey. But in need that the nginx use memcache even in a POST petition.
    – Tim
    Sep 19, 2012 at 13:06
  • Well.. Please, describe the detailed algorithm of caching for POST requests. Give me an example of it. Maybe, we could think out something working.
    – Dingo
    Sep 21, 2012 at 23:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .