Problem with cache key

CarstenK. nginx-forum at forum.nginx.org
Mon Oct 17 13:50:15 UTC 2016


Hello, 
i have a problem. 

If i send a request to url A with Chrom and another request with curl or
firefox i have a cache miss. 
If isend a request to the same url with curl on two different machines the
answer is a cache hit, thats fine. 

But i don't know, why ich became a cache miss if i test with Chrome/Firefox,
Chrome/curl or Firefox/curl on the second request. 

curl -I http://meinedomain/test.html 

I think it is a problem with cache_key but i can't find the reason. 

First step i only consider the url with arguments, no cookie or something
else. In a further step i want to consider a special cookie. 


Version: nginx version: nginx/1.11.3 (nginx-plus-r10) (30 days trial) 

Hier meine Konfiguration 
### proxy.conf 
proxy_cache_path /srv/nginx/cache/test levels=1:2 keys_zone=test_cache:128m
inactive=120d max_size=25G; 

map $request_method $purge_method { 
PURGE 1; 
default 0; 
} 

server { 
listen 80; 
server_name <meineDomain.de>; 
access_log /var/log/nginx/fliesenrabatte.access.log shop; 
error_log /var/log/nginx/fliesenrabatte.error.log; 
proxy_cache fliesenrabatte_cache; 

rewrite_log on; 
proxy_set_header Host <meineDomain.de>; 

proxy_cache_key $request_uri; 



# Caching deaktivieren 
# NoCache URLs 
if ($request_uri ~* "(/admin.*|/brand.*|/user.*|/login.*)") { 
set $no_cache 1; 
} 

proxy_no_cache $no_cache; 




# Startseite 
location ~ /$ { 
proxy_ignore_headers "Set-Cookie"; 
proxy_hide_header "Set-Cookie"; 
proxy_pass http://meinupstream; 
proxy_cache_purge $purge_method; 
} 

# Cachen 
location ~* \.(html|gif|jpg|png|js|css|pdf|woff|woff2|otf|ttf|eot|svg)$ { 
proxy_ignore_headers "Set-Cookie"; 
proxy_hide_header "Set-Cookie"; 
proxy_pass http://meinupstream; 
proxy_cache_purge $purge_method; 
} 

# nicht cachen (Warenkorb usw) 
location ~* \.(cfc|cfm|htm)$ { 
proxy_cache off; 
proxy_pass http://meinupstream; 
} 

# Fuer Wildcard purging notwendig, da String auf Wildcard endet 
location / { 
allow 1.1.1.1; 
deny all; 
proxy_ignore_headers "Set-Cookie"; 
proxy_hide_header "Set-Cookie"; 
proxy_pass http://meinupstream; 
proxy_cache_purge $purge_method; 
} 

} 




### site-conf 
server_tokens off; 
proxy_ignore_headers X-Accel-Expires Expires Cache-Control; 
proxy_cache_valid 200 120d; 
proxy_set_header Host $http_host; 
proxy_set_header X-Real-IP $remote_addr; 
add_header X-Cache-Status $upstream_cache_status; 


upstream meinupstream { 
server meinedomain.de:80; 
} 


I hope someone can help me. 
Sorry for my bad english :( 

Best, 
Carsten

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,270324,270324#msg-270324



More information about the nginx mailing list