Does the expires directive add the head if the Expire head not exist?
Delta Yeh
delta.yeh at gmail.com
Mon Aug 18 08:37:40 MSD 2008
So the only question remained is : Is it possible to set Expire
header according to the response Content-Type in nginx?
2008/8/18 Delta Yeh <delta.yeh at gmail.com>:
> I think it's because ncache2.0 module.
>
> I built nginx 0.7.10 with ncache2.0 but i didn't turn it on in my conf.
>
> When I use if ( $request_uri ~* ^.+.(css|jpg|jpeg|gif)$ ) {
> #if ( $content_type ~ css ) {
> expires max;
>
>
> }
>
> I the error log is :
>
> 2008/08/18 10:11:16 [notice] 5589#0: using the "epoll" event method
> 2008/08/18 10:11:16 [notice] 5589#0: nginx/0.7.10
> 2008/08/18 10:11:16 [notice] 5589#0: built by gcc 4.1.2 20061115
> (prerelease) (Debian 4.1.1-21)
> 2008/08/18 10:11:16 [notice] 5589#0: OS: Linux 2.6.22.18-co-0.7.3
> 2008/08/18 10:11:16 [notice] 5589#0: getrlimit(RLIMIT_NOFILE): 1024:1024
> 2008/08/18 10:11:16 [notice] 5595#0: start worker processes
> 2008/08/18 10:11:16 [notice] 5595#0: start worker process 5596
> 2008/08/18 10:12:26 [notice] 5595#0: signal 17 (SIGCHLD) received
> 2008/08/18 10:12:26 [alert] 5595#0: worker process 5596 exited on signal 11
> 2008/08/18 10:12:26 [notice] 5595#0: start worker process 5602
> 2008/08/18 10:12:32 [notice] 5595#0: signal 17 (SIGCHLD) received
> 2008/08/18 10:12:32 [alert] 5595#0: worker process 5602 exited on signal 11
> 2008/08/18 10:12:32 [notice] 5595#0: start worker process 5608
> 2008/08/18 10:13:20 [notice] 5595#0: signal 17 (SIGCHLD) received
> 2008/08/18 10:13:20 [alert] 5595#0: worker process 5608 exited on signal 11
> 2008/08/18 10:13:20 [notice] 5595#0: start worker process 5625
>
>
> But when I build without ncache2.0 , the same conf works as expected.
> I will report the bug to the author of ncache.
>
> 2008/8/18 Delta Yeh <delta.yeh at gmail.com>:
>> 2008/8/18 Maxim Dounin <mdounin at mdounin.ru>
>>>
>>> Hello!
>>>
>>> On Sun, Aug 17, 2008 at 07:27:38PM +0800, Delta Yeh wrote:
>>>
>>>> I use
>>>>
>>>> location / {
>>>> proxy_redirect off;
>>>> proxy_redirect default;
>>>
>>> JFYI:
>>>
>>> "proxy_redirect default" is useless here since redirects was switched off by "proxy_redirect off".
>>>>
>>>> #if ( $request_uri ~* ^.+.(css|jpg|jpeg|gif)$ ) {
>> I had thought proxy_redirect off first clear all previous proxy
>> redirect settings, then the second proxy_redirect default will
>> define a clean default settings. Maybe I 'm wrong.
>>>
>>> JFYI:
>>>
>>> Since last dot in regex isn't escaped, this expression will match something like "/some-notes-about-css" as well as "/style.css".
>>
>> Aha, I only copied it from others configuration for my test, but
>> thank you anyway, I will tweak it in production environment later.
>>
>>
>>>> if ( $content_type ~* css ) {
>>>
>>> Variable $content_type contains Content-Type header value from *request*. It's unlikely that request will contain css in it's Content-Type.
>>>
>>> See http://wiki.codemongers.com/NginxHttpCoreModule#var_content_type
>>
>> I think Content-Type value can be text/css .
>>
>>>> expires 1h;
>>>>
>>>> }
>>>>
>>>> proxy_pass http://my_upstream;
>>>>
>>>> }
>>>>
>>>> but it does not work.
>>>>
>>>> when I use $request_uri the browser get error response. It seems the nginx
>>>> box reset the tcp connection.
>>>
>>> I've just checked and with $request_uri it works as expected. I.e. nginx adds Expires and Cache-Control headers to response if .
>>>
>>> Try tcpdump / error log / error log at debug level to figure out what's actually happening.
>> I will try again and share with others what mistake I had made, ^_^
>>>> when I use $content_type no Expires head returned by nginx.
>>>
>>> Also as expected, see above.
>>>
>>> Maxim Dounin
>>>
>>
>
More information about the nginx
mailing list