Welcome! Log In Create A New Profile

Advanced

Cache only static files in sub/subfolder but not sub

February 19, 2017 02:53PM
Hi, I'm having as so many other a subfolder with media files, but I've like to do a simple file caching of only one of the subfolders = /media//thumbs/embedded with path insite the domain.tld and serve them as media.domain.tld

So what I have done is added this to my config and it's working fine when I out comments the second location directive, files are stored in the cache and served as expected.
Now the trouble shooting: as noticed above, this only works when I out comments the second location, which is NOT to be cached at all. I have of course tried to switch between which location comes first. Even chose I recall it as first rule matching is served first.

Any one who can tell me why this isn't working as i like it to?

(for those who is curious, the location /thumbs/embedded holds about 4.200.000 files, where the rest is logically stored in same folder. The other folders is divided into sub1/sub2/sub3/sub4/sub5, this one isn't)

location /thumbs/embedded {
add_header X-Served-By "IDENT1";
add_header Cache-Control public;
add_header Pragma 'public';
add_header X-Cache-Status $upstream_cache_status;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
error_page 404 = /image404.php;
proxy_pass http://127.0.0.1:9001;
}

##Match what's not in above location directive
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
#access_log on;
#log_not_found on;
aio on;
sendfile on;
expires max;
add_header Cache-Control public;
add_header Pragma 'public';
add_header X-Served-By "IDENT2";
#add_header X-Frame-Options SAMEORIGIN;
error_page 404 = /image404.php;
}
Subject Author Posted

Cache only static files in sub/subfolder but not sub

JoakimR February 19, 2017 02:53PM

Re: Cache only static files in sub/subfolder but not sub

JoakimR February 20, 2017 07:52AM

Re: Cache only static files in sub/subfolder but not sub

Francis Daly February 20, 2017 02:08PM

Re: Cache only static files in sub/subfolder but not sub

JoakimR February 22, 2017 11:01AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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