Opened 7 years ago

Closed 6 years ago

#375 closed defect (invalid)

Unable to do if checking on $sent_http_content_type

Reported by: Silver Moonstone Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.3.x
Keywords: Cc:
uname -a: Linux enlightened 3.5.0-32-generic #53-Ubuntu SMP Wed May 29 20:23:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: $ nginx -V
nginx version: nginx/1.4.1
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --with-pcre-jit --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.4.1/debian/modules/nginx-auth-pam --add-module=/build/buildd/nginx-1.4.1/debian/modules/nginx-dav-ext-module --add-module=/build/buildd/nginx-1.4.1/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.4.1/debian/modules/nginx-upstream-fair --add-module=/build/buildd/nginx-1.4.1/debian/modules/ngx_http_substitutions_filter_module

Description

This does not have any effect

if ( $sent_http_content_type = "text/css" ) {

expires 7d;

}

When the resource being requested is a css file, expires headers are not being send
It has been verified that $sent_http_content_type does contain "text/css".

Change History (4)

comment:1 by Maxim Dounin, 7 years ago

Resolution: invalid
Status: newclosed

The "if" directive, much like other rewrite module directives, are executed during rewrite phase before a request is handled (and before a response is generated. See documentation at http://nginx.org/en/docs/http/ngx_http_rewrite_module.html.

comment:2 by Silver Moonstone, 7 years ago

Resolution: invalid
Status: closedreopened

so how to achieve what i am trying to do ?

comment:3 by Maxim Dounin, 7 years ago

Recommended approach is to configure separate location for resources which need to have distinct expires added, i.e.

location /images/ {
    expires 7d;
}

It is bad idea to ask questions here though, use mailing list instead.

comment:4 by Maxim Dounin, 6 years ago

Resolution: invalid
Status: reopenedclosed
Note: See TracTickets for help on using tickets.