I would like to warn the community about serving multiple pages up based on the exact same request url (which is what the code below can contribute to). There are an awful lot of network caches out there, and many of them intercept requests transparently, without informing the client. These caches will cache the first document that it gets a request for, and then serve it for all subsequent requests. This means that if a 3.0 browser grabs this page first, all subsequent 4.0 browsers will get the non stylesheet page. This is bad. There are mechanisms built into http/1.1 (netscape isn't there yet, and I don't know about Opera) that allow a server to mark a page as varying on a particular header (Vary: user-agent, or something similar), which should cause a cache to cache different copies of the object for each user-agent request that it sees. However, most caches ignore this command, since few authors do this anymnore (they learned the hard way). In general, it is best to detect css support in javascript, or design pages that work with or wothou CSS support. In other instances, if you must do a detection, get the results and then issue a redirect to the correct page (make sure it is a temporary redirect, not a permanent one, since the permanent redirect is considered a cachable object in most caches). If you thin that this is a non-issue, just be aware that AOL's entire network is cached by transparent caches, and that is 20 million web browsers of all shapes and sizes. --sam Ben Glazer wrote:
I saw your Nov 1999 post about sensing browser abilities.
Did you ever get an answer?
No, I didn't. :( However, I did come up with a workable (though certainly not elegant) solution on my own. (I hope you don't mind that I'm copying this message to the Zope list -- this might be useful to other people.)
What I currently do (which is a bit of a kludge) is check to see whether the client's browser reports itself as compatible with Mozilla/4 or Mozilla/5 (Netscape Navigator, MS Internet Explorer, and Opera all pass this test). All I want to know is whether the browser includes ANY support for CSS, rather than what level of CSS support is provided. Your needs may be different.
In case you're interested, the specifics of my implementation follow.
I've written an external method called supportsCSS:
import re
def supportsCSS(self): """Checks (sort of) whether requesting browser supports stylesheets."""
if re.match('Mozilla/[45]', self.REQUEST.environ['HTTP_USER_AGENT']): return 1 else: return 0
Note that the version string test is hard-coded as a very simple regex. This (unfortunately) needs to be kept in mind for future browser changes (e.g. Mozilla 6.0).
In my standard_html_header, I include something like:
<dtml-if supportsCSS> Supports CSS. (Feel free to include stylesheets, etc.) <dtml-else> No CSS support. :( </dtml-if>
Please let me know if you have any questions or suggestions for improvement.
Regards, Ben
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Sam Gendler Chief Technology Officer - Impossible, Inc. 1222 State St. Suite 250 Santa Barbara CA. 93101 w: 805-560-0508 f: 805-560-0608 c: 805-689-1191 e: sgendler@impossible.com