I'm having some trouble defining a rule to cache my static files. I've found this solution:
location ~* .(ico|js|css|png|gif|jpe?g)$ {
expires 7d;
}
which actually looks like what I need. The problem is, if I include this code into my NGINX.conf, no static files are delivered anymore and my site is blank. Any ideas/hints what might cause this result? Maybe I have to add, that the static files are distributed in different directories :/. My NGINX config file looks like this:
server {
server_name bla.domain.com;
listen 80;
root /var/repo/;
location / {
default_type text/html;
index index.html;
if ($request_method !~ ^(GET)$ ) {
return 444;
}
if ($http_user_agent ~* LWP::Simple|BBBike|wget) {
return 403;
}
if ( $http_referer ~* (babes|forsale|girl|jewelry|love|nudit|organic|poker|porn|sex|teen) ) {
return 403;
}
}
location /bf/football/ {
alias /var/repos/f20;
}
location /bf/f20/ {
alias /var/repo/f20;
}
location /bf/zoo/ {
alias /var/repo/zoo/;
}
location /kbloader/ {
alias /var/repo/kbloader/;
}
}
Would be nice if someone could help me out with this or point me in the right direction.
question from:
https://stackoverflow.com/questions/19515132/nginx-cache-static-files 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…