Hi.
I'm trying to sort out expires headers for my rails app.
I'm trying two approaches, neither of which seem to work:
----------
Approach 1 - (simple expires in if block):
location / {
if ( $request_uri ~* \.(css|js|gif|jpe?g|png|ico|htc)\?ts_ ) {
expires max;
}
if (-f $request_filename) {
break;
}
proxy_pass http://app_servers;
}
This doesn't work at all unless I put a break; within the if block (same
problem as: http://www.ruby-forum.com/topic/129953)
----------
Approach 2 - (set expires variable into a variable):
location / {
set $expires_value -1;
if ( $request_uri ~* \.(css|js|gif|jpe?g|png|ico|htc)\?ts_ ) {
set $expires_value max;
}
if (-f $request_filename) {
expires $expires_value;
break;
}
proxy_pass http://app_servers;
expires $expires_value;
break;
}
This gives me an emerg message: "expires" directive invalid value in
conf_file
Can anyone help with this?
Thanks, Rob
on 11.08.2008 20:57
on 12.08.2008 09:37
On Mon, Aug 11, 2008 at 08:57:09PM +0200, Rob Dupuis wrote: > expires max; > problem as: http://www.ruby-forum.com/topic/129953) > > This gives me an emerg message: "expires" directive invalid value in > conf_file The expires directive does not support varaibles. All these nginx's if's and break's are ugly constructions. Do you want set max expires for URLs like "/some.gif?ts_anything" ? Should these URLs proxied to app_servers ?
on 12.08.2008 11:50
Igor Sysoev wrote: > Do you want set max expires for URLs like "/some.gif?ts_anything" ? > Should these URLs proxied to app_servers ? The problem is I have some dynamically created images which do need to be handled by the app server and cached the first time they are created. Subsequently, they can be served statically by nginx. Therefore I want to set the expires header the very first time the image is created by the app server, and then continue to send it for the static cached version.