Welcome! Log In Create A New Profile

Advanced

proxy_cache_bypass и 303 see other

July 14, 2013 10:53AM
Здравствуйте,
Подскажите как сделать конструкцию для отключения кэширования страницы открывающейся по 303 see other?
на подобии:

if ( $http_responce = 303 ) {
set $do_not_cache 1;
}
proxy_cache_bypass $do_not_cache;


Предистория:

nginx version: nginx/1.0.15
CentOs 6
Linux 2.6.32-358.2.1.el6.x86_64 #1 SMP Wed Mar 13 00:26:49 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux


nginx установлен в качестве прокси для apache2 + отдача статики.
Возникла необходимость кешировать один из сайтов, в результате родился такой конфиг:
/etc/nginx/nginx.conf

user apache;
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {worker_connections 1024;}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
keepalive_timeout 85;
proxy_cache_path /var/cache/nginx levels= keys_zone=wholepage:500m;

include /etc/nginx/conf.d/*.conf;

include /usr/local/ispmgr/etc/nginx.domain;
client_max_body_size 64M;
log_format isp '$bytes_sent $request_length';

server {
server_name test3.mysite.ru www.test3.mysite.ru;
listen 33.133.9.32;
set $root_path /var/www/mysite.ru/data/www/test3.mysite.ru;
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
root $root_path;
access_log /var/www/nginx-logs/mysite.ru isp;
access_log /var/www/httpd-logs/test3.mysite.ru.access.log ;
error_page 404 = @fallback;
}
location / {
if ($request_method = POST) { set $do_not_cache 1; }
if ($cookie_session) { set $do_not_cache 1; }
proxy_cache_bypass $do_not_cache;

proxy_pass http://33.133.9.32:81;
proxy_redirect http://33.133.9.32:81/ /;

proxy_hide_header "Set-Cookie";
proxy_ignore_headers "Cache-Control" "Expires" "Set-Cookie";

proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;

proxy_cache wholepage;
proxy_cache_valid 200 301 302 304 5m;
proxy_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$host|$request_uri";
}

location ~* ^/(webstat|awstats|webmail|myadmin|pgadmin)/ {
proxy_pass http://33.133.9.32:81;
proxy_redirect http://33.133.9.32:81/ /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location @fallback {
proxy_pass http://33.133.9.32:81;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location ^~ /webstat/ {
auth_basic "Restricted area";
auth_basic_user_file /var/www/mysite.ru/data/etc/3677707.passwd;
try_files $uri @fallback;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|ico)$ {
root $root_path;
access_log /var/www/nginx-logs/mysite.ru isp;
access_log /var/www/httpd-logs/test3.mysite.ru.access.log ;
error_page 404 = @fallback;
}
include /usr/local/ispmgr/etc/nginx.inc;
}
server_names_hash_max_size 8192;
}

на сайте есть корзина, при нажатии на ссылку открывается страница с кодом 303 see other, мне нужно чтобы страница которая по 303 вернулась не кэшаровалась, как это сдлеать?
Subject Author Posted

proxy_cache_bypass и 303 see other

commeta July 14, 2013 10:53AM

Re: proxy cache bypass и 303 see other

Maxim Dounin July 15, 2013 06:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 288
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