fastcgi_hide_header inside an IF statement

Igor Sysoev is at rambler-co.ru
Fri Sep 18 20:02:58 MSD 2009


On Fri, Sep 18, 2009 at 06:42:39PM +0300, Kaspars Dambis wrote:

> I have two php scripts (css.php and js.php) which combine all css and js
> files. To make things faster on the client side, I want to
> 
>    - set expires header to far future
>    - not set cookies for those request
> 
> Here is what works now:
>         location ~ \.php$ {
>                 # php cgi stuff goes here
> 
>                 if ($request_uri ~ (css|js)\.php) {
>                         expires max;
>                 }
>         }
> 
>         location ~ (css|js)\.php {
>                 fastcgi_hide_header Set-Cookie;
>         }
> 
> The question is -- why it's not allowed to use *fastcgi_hide_header
> Set-Cookie;* inside the if () { ... } statement?

Because "if" is ugly hack. Period.

You should use

     location = /css.php {
         # php stuff
         fastcgi_hide_header Set-Cookie;
         expires max;
     }

     location = /js.php {
         # php stuff
         fastcgi_hide_header Set-Cookie;
         expires max;
     }


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list