Welcome! Log In Create A New Profile

Advanced

Problem with cache key

Posted by CarstenK. 
Problem with cache key
October 14, 2016 11:33AM
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
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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