Fastcgi_hide_header inside an IF statement

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?

Regards,
Kaspars

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

            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;
 }

Because “if” is ugly hack. Period.

Got it. Spasiba, Igor.
I’ll stick with the solution I previously mentioned – it works
perfectly. I
was just thinking if there is a more ‘elegant’ solution possible.

With warm greeting from Latvia,
Kaspars

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs