There is a directory on my webserver which contains images that I don't want to be cached.
Nginx is frontend to Apache. I have caching enabled for static resources in nginx.conf:
server {
listen 80;
server_name www.mydomain.com mydomain.com;
location / {
root /home/somedomain/public_html/site;
proxy_pass http://backend;
include /etc/nginx/proxy.conf;
}
location ~* \.(css|js)$ {
root /home/somedomain/public_html/site;
add_header Last-Modified: $date_gmt;
expires 1y;
access_log off;
}
location ~* \.(jpg|jpeg|gif|png|ico|bmp|swf)$ {
root /home/somedomain/public_html/site;
expires max;
access_log off;
}
location ~ \.php {
proxy_pass http://backend;
include /etc/nginx/proxy.conf;
}
}
I tried to add to the end:
location /home/somedomain/public_html/site/dontcache/ \.png {
root /home/somedomain/public_html/site/dontcache;
expires off;
}
Also tried expires -1;
and expires 1m;
but all of that doesnt seem to work.
I know it is simple but I just can't get why it doesnt work for me.