Discussion:
fastcgi_hide_header inside an IF statement
Kaspars Dambis
2009-09-18 15:42:39 UTC
Permalink
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
Igor Sysoev
2009-09-18 16:02:58 UTC
Permalink
Post by Kaspars Dambis
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
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/
Kaspars Dambis
2009-09-18 18:37:33 UTC
Permalink
Post by Igor Sysoev
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

Loading...