Ramon Fincken
31/07/16, 17:24
Ik zoek iemand die kan meekijken naar een exclude optie waarbij ik bij een aanroep op een bepaald path kan zeggen dat nginx GEEN microcaching moet toepassen.
dit is globaal de setup, de UPPERCASINGS zijn placeholders
belangrijk om te weten: deze nginx server heeft zelf geen data of webfiles, alles gaat via een proxy naar een de source server
location / {
proxy_pass http://http_backend_DOMAINESCAPED;
proxy_set_header Host DOMAIN;
proxy_cache mcDOMAINESCAPED;
include /etc/nginx/mpincludes/microcaching.conf;
}
en dan in die microcaching.conf (enkel de relevante stukken hier), indien ik site.ext/dashboard aanroep dan gaat hij alsnog cachen ..
proxy_cache_valid 200 60m;
proxy_cache_valid 301 302 5m;
proxy_cache_valid 404 30s;
proxy_cache_valid 500 15s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto-origin $hostname;
#Cache everything by default
set $no_cache 0;
if ($request_uri ~* "/store.*|/cart.*|/my-account.*|/dashboard.*|/checkout.*|/addons.*|/order.*|/winkel.*|/betalen.*") {
set $no_cache 50;
}
if ($query_string ~ "add-to-cart") {
set $no_cache 51;
}
if ($request_method = POST) {
set $no_cache 10;
}
# proxy_temp_path /tmp;
# Set cache key to include identifying components
proxy_cache_key "$scheme$host$request_method$request_uri$my_cookie";
proxy_pass_header Set-Cookie;
fastcgi_cache_bypass $no_cache $my_cookie; # Don't pull from cache based on $do_not_cache
fastcgi_no_cache $no_cache $my_cookie; # Don't save to cache based on $do_not_cache
fastcgi_ignore_headers Cache-Control Expires;
proxy_cache_revalidate on; # Preload
fastcgi_cache_methods GET HEAD; # Only GET and HEAD methods apply
# Serve from cache if currently refreshing
fastcgi_cache_use_stale updating error timeout invalid_header http_500;
fastcgi_cache_lock on;
fastcgi_cache_lock_timeout 10s;
add_header X-Cache $upstream_cache_status;
add_header X-Cached $no_cache;
dit is globaal de setup, de UPPERCASINGS zijn placeholders
belangrijk om te weten: deze nginx server heeft zelf geen data of webfiles, alles gaat via een proxy naar een de source server
location / {
proxy_pass http://http_backend_DOMAINESCAPED;
proxy_set_header Host DOMAIN;
proxy_cache mcDOMAINESCAPED;
include /etc/nginx/mpincludes/microcaching.conf;
}
en dan in die microcaching.conf (enkel de relevante stukken hier), indien ik site.ext/dashboard aanroep dan gaat hij alsnog cachen ..
proxy_cache_valid 200 60m;
proxy_cache_valid 301 302 5m;
proxy_cache_valid 404 30s;
proxy_cache_valid 500 15s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto-origin $hostname;
#Cache everything by default
set $no_cache 0;
if ($request_uri ~* "/store.*|/cart.*|/my-account.*|/dashboard.*|/checkout.*|/addons.*|/order.*|/winkel.*|/betalen.*") {
set $no_cache 50;
}
if ($query_string ~ "add-to-cart") {
set $no_cache 51;
}
if ($request_method = POST) {
set $no_cache 10;
}
# proxy_temp_path /tmp;
# Set cache key to include identifying components
proxy_cache_key "$scheme$host$request_method$request_uri$my_cookie";
proxy_pass_header Set-Cookie;
fastcgi_cache_bypass $no_cache $my_cookie; # Don't pull from cache based on $do_not_cache
fastcgi_no_cache $no_cache $my_cookie; # Don't save to cache based on $do_not_cache
fastcgi_ignore_headers Cache-Control Expires;
proxy_cache_revalidate on; # Preload
fastcgi_cache_methods GET HEAD; # Only GET and HEAD methods apply
# Serve from cache if currently refreshing
fastcgi_cache_use_stale updating error timeout invalid_header http_500;
fastcgi_cache_lock on;
fastcgi_cache_lock_timeout 10s;
add_header X-Cache $upstream_cache_status;
add_header X-Cached $no_cache;