Why are you varying the CSS or javascript?

If it's to deal with quirks in different web browsers, and you're trying to serve slightly different versions based on the browser, then I'd recommend that instead of generating the CSS or JS dynamically, you instead generate the references to the correct file dynamically, and have the files themselves be static (or not... see below)

As for the caching issues, you can manipulate things using the correct headers, such as 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 Cache-control', you can get around things -- if it's possible that you might send different versions to the same browser (which is not the case when dealing with browser quirks), then you just need to make the URL formatted in such a way that the browser will consider them differently, while still using GET.

Instead of using a URL passing the info in QUERY_STRING:

http://www.example.com/cgi/generator?id

You should instead pass the date in PATH_INFO:

http://www.example.com/cgi/generator/id

With Cache-control, you can insure that the pages will be cached, and with the differing URLs, you can get the browser to treat different versions as seperately identifiable files.

I'd be interested in knowing exactly what it is that you're trying to accomplish -- there may be better solutions (eg, a 'main' css file, and some pages reference the main file + specific modifications for that page)


In reply to Re: Javascript/CSS on the fly by jhourcle
in thread Javascript/CSS on the fly by indiansummersky

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.