September 15, 2011 01:52AM
On Thu, Sep 15, 2011 at 01:43:38AM -0400, qzpmwo wrote:
> Hi everybody,
>
> I'm a newbie with nginx and would like to ask your help. On potentially
> very high loaded site I would like to cache response to the HTTP POST
> for the few seconds. Works perfectly for GETs, but...
>
> nginx version: nginx/0.8.54
>
> Please see below my config:
>
> proxy_cache_path /tmp/nginx levels=2:2:2 keys_zone=small:1m inactive=1m
> max_size=10m;
>
> server {
>
> log_format main '$remote_addr $host $remote_user [$time_local]
> "$request" $status $body_bytes_sent "$http_referer"
> "$http_user_agent" "$gzip_ratio"';
>
> access_log /var/log/nginx/test_server.access.log main buffer=32k;
> error_log /var/log/nginx/test_server.error.log info;
>
>
> listen 80;
>
> root /var/www/html/nginx;
> index index.html index.htm;
>
> location / {
> try_files $uri @apache_backend;
> }
>
> ### location ~ \.php$ {
> ### proxy_pass http://127.0.0.1:88;
> ### }
>
> location @apache_backend {
> proxy_pass http://127.0.0.1:88;
> proxy_cache small;
> proxy_cache_valid 5s;
> proxy_cache_key $uri;
> proxy_cache_use_stale updating;
> add_header X-Cached $upstream_cache_status;
> }
> }
>
>
> Any help/advices will be appreciated.

You should upgrade to at least 0.8.55.
If POST request body is small enough, then you can use:

location @apache_backend {
...
proxy_cache_methods POST;
proxy_cache_key "$uri|$request_body";
client_max_body_size 1k;
}


--
Igor Sysoev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to force nginx to cache HTTP POST response for few seconds

qzpmwo September 15, 2011 01:43AM

Re: How to force nginx to cache HTTP POST response for few seconds

Igor Sysoev September 15, 2011 01:52AM

Re: How to force nginx to cache HTTP POST response for few seconds

qzpmwo September 15, 2011 03:09AM

Re: How to force nginx to cache HTTP POST response for few seconds

Igor Sysoev September 15, 2011 05:30AM

Re: How to force nginx to cache HTTP POST response for few seconds

qzpmwo September 15, 2011 05:33AM

Re: How to force nginx to cache HTTP POST response for few seconds

qzpmwo September 15, 2011 05:44AM

Re: How to force nginx to cache HTTP POST response for few seconds

qzpmwo September 15, 2011 07:22PM

Re: How to force nginx to cache HTTP POST response for few seconds

qzpmwo September 15, 2011 01:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 170
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready