Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm using mod_perl/Mason. I have a page with, say, six IF BROWSER conditionals. Rather than have all six of these conditionals evaluated with each page request, I'd like to "publish" two versions of the page (e.g., "ie/page.htm" and "netscape/page.htm"), then have Apache redirect to the right page based upon the browser type.

(This is just an example... my real question is "what's the best way generate pages at publish time, based upon a conditional embedded in the page?")

Replies are listed 'Best First'.
•Re: publish-time conditionals w. Mason?
by merlyn (Sage) on Apr 25, 2003 at 21:39 UTC
    Ugh. The days of the browser-conditional pages should be long gone. What happens when a corporate proxy caches your page? How will it know which version to cache?

    Please don't do browser-sniffing. Just write good HTML. If you want more control over the layout, use PDF.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Well, for example, both Yahoo's and Microsoft's homepages do both client- and server-side browser sniffing, so we're a ways off from seeing the practice disappear.

      Also, for specialized design-intensive sites, you may want to do some tweaks... minor stuff, and if it's cached, then no big deal... just won't look quite as nice. And, of course, you can turn caching off for your page, add random values to URLs to get around poorly-built corporate caches that ignore the cache flags in the server response, etc.

      But, the main point is that, for artists/designers, there is still a need to be browser-specific for certain web projects where to-the-pixel control is needed.

      But, as I said in my post... the browser sniffinf was just an example. I really just want to know how to best handle publish-time conditionals in a general sense.