Welcome! Log In Create A New Profile

Advanced

Different Expiration For Different Locations? How?

Posted by qops1981 
Different Expiration For Different Locations? How?
September 30, 2013 01:08PM
Hey All,

I am new to the forums and have a question that I was not able to find an answer for via googling. I have some conditional expiration dates I would like to set up but I was hoping to avoid some complicated (IF) statement. I will just give the requirements.

All jpg|jpeg|gif|png|css|js|ico|xml files should have an expiration of 2 days.

All jpg|jpeg|gif|png|js in ^/styles/ & ^/js/ should have an expiration on 31 days.
http://domain.com/styles/default/xenforo/icons/image.png
http://domain.com/js/script.js

And All jpg|jpeg|gif|png with a series of numbers at the end should have an expiration of 1 hour.
http://domain.com/data/avatars/s/0/15.jpg?1379247393

I tried all four as individual locations, but they all took the first 2 day entry. feel free to simply direct me to a resource if you like. Just because I didn't find it on the web, doesn't mean it isn't there.

Here is what I have as the first entry which obviously is overriding every other condition I enter.

location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 2d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

Thanks,
-Bill



Edited 2 time(s). Last edit at 09/30/2013 01:13PM by qops1981.
Re: Different Expiration For Different Locations? How?
September 30, 2013 01:43PM
ok, so would this override the Location above?

location ^~ /(styles|js|cometchat)/\.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 31d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
Re: Different Expiration For Different Locations? How?
September 30, 2013 02:35PM
ok, I tried this (below), But its still not working:

location ^~ /(styles|js|cometchat)/.*\.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 31d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 2d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 148
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready