Is it a bad idea to use a php css file?

I just want to know if it’s a good or bad idea to use a php css file performance wise. I really want to do a php method for the use of variables.

By php css file I mean:

Read More
<?php header("Content-type: text/css"); ?>

What are your thoughts on this?

Related posts

Leave a Reply

3 comments

  1. Nope, it’s fairly common in the wild. The only performance hit is when you output the file dynamically, which can be mitigated easily with server-side (and client side) caching.

  2. This is a bad idea, but only if you don’t cache.

    On the server side, I expect that you’re using some sort of global site-level variables, then building your CSS from that. Fine, just make sure that you save the file, invalidating it whenever it needs to change (say, from an SVN checkin).

    From the client’s perspective, you want to ensure that it doesn’t have to download it on every page load. For that you’ll need to properly set last-modified headers or an Etag.

  3. I don’t think it’s a bad idea, and I’m currently doing it in that way. In my framework I dynamically concatenate two css groups in two separate files, the site main CSSs (layout, forms, etc) and some module specific ones if they exists. So, they can be cached separately. I also include some dynamic path inside using php vars.