Book HomeApache: The Definitive GuideSearch this book

4.6. Setting Environment Variables

When a script is called it receives a lot of environment variables, as we have seen. It may be that you want to pass some of your own. There are two directives to do this: SetEnv and PassEnv.

4.6.4. Browsers

A real problem on the Web is that people are free to choose their own browsers and not all browsers work alike or even nearly alike. They vary enormously in their capabilities. Some browsers display images, others won't. Some that display images won't display frames, tables, or Java, and so on.

You can try to circumvent this problem by asking the customer to go to different parts of your script ("Click here to see the frames version"), but in real life people often do not know what their browser will and won't do. A lot of them will not even understand what question you are asking. To get around this problem, Apache can detect the browser type and set environment variables so that your CGI scripts can detect the type and act accordingly.

4.6.5. Internal Use of Environment Variables

Environment variables can also be used to control some aspects of the behavior of Apache. Note that because these are just environment variables, nothing checks that you have spelt them correctly, so be very careful when using them.

4.6.5.1. nokeepalive

This disables KeepAlive (see Chapter 3, "Toward a Real Web Site"). Some versions of Netscape claimed to support KeepAlive, but actually had a bug that meant the server appeared to hang (in fact, Netscape was attempting to reuse the existing connection, even though the server had closed it). The directive:

BrowserMatch "Mozilla/2" nokeepalive

disables KeepAlive for those buggy versions.[42]

[42]And, incidentally, for early versions of Microsoft Internet Explorer, which unwisely pretended to be Netscape Navigator.



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.