Настраиваю кэширование на сайте joomla, nginx в качестве кэширующего прокси для apache2.
Есть страница которая отдает заголовок 303 see other
Ситуация: php страница допустим index.php, на ней ссылка href=/add.html?product_id=238 нажимаем на ссылку, add.html возвращает заголовок
HTTP/1.1 303 See other
Server: nginx/1.0.15
Date: Sun, 14 Jul 2013 16:18:06 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
X-Powered-By: PHP/5.3.3
Cache-Control: no-cache, must-revalidate
Location: http://test2.mysite.ru/index.php
Content-Length: 0
что то типа if ($refer from header = 303) { set $do_not_cache 1; }
мой конфиг:
/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 xxx.xxx.xxx.xxx;
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 ($cookie_session) { set $do_not_cache 1; }
if ($request_method = POST) { set $do_not_cache 1; }
if ($request_uri ~* "administrator|korzina|cart") { set $do_not_cache 1; }
proxy_cache_bypass $do_not_cache;
proxy_no_cache $do_not_cache;
proxy_pass http://xxx.xxx.xxx.xxx:81;
proxy_redirect http://xxx.xxx.xxx.xxx: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://xxx.xxx.xxx.xxx:81;
proxy_redirect http://xxx.xxx.xxx.xxx: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://xxx.xxx.xxx.xxx: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;
}