Steve ([info]akicif) wrote,
@ 2007-11-30 16:00:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
The Power....
Just seen this on a mailing list:

To .htaccess, add:
addtype x-httpd-php .css
To your css files, add:
<? header('Content-Type: text/css');?> (corrected: thanks, [info]drplokta)
There's one "feature" to look out for - these CSS files aren't cached, but generated each time they're served. You can either take advantage of this, or Do Stuff in httpd.conf to fix it....

Now, where's a nail I can test my nice new hammer on?


(Post a new comment)


[info]drplokta
2007-11-30 04:34 pm UTC (link)
Surely that should be:

<? header('Content-Type: text/css');?>

(Reply to this)(Thread)


[info]akicif
2007-11-30 04:48 pm UTC (link)
Yup, thanks. Typed from paper copy, rather than cut and pasted (does anyone else find they make ineffectual mouse gestures at paper they're typing from?)

(Reply to this)(Parent)


[info]figg
2007-11-30 05:26 pm UTC (link)
Why is this a good idea? You're just now running the php interpreter every time someone requests a css file.

They will still be cached on the browser side.

(Reply to this)(Thread)


[info]skx
2007-11-30 05:43 pm UTC (link)
Only think I can think of is if you want to have per-user themes.

But there are better ways of doing that.

(Reply to this)(Parent)


[info]akicif
2007-11-30 05:45 pm UTC (link)
Not sure if it is a good one. It just looked like it could be fun to play with for reskinning/remodelling purposes. And it's allegedly possible to use "If-Modified-Since" to stop having to regenerate the css file unnecessarily....

Edited at 2007-11-30 05:46 pm UTC

(Reply to this)(Parent)(Thread)


[info]zombywuf
2007-12-03 01:26 pm UTC (link)
Yeah but no-one ever uses it. In fact 99.99% of websites go out of their way to prevent caches form doing their job. Varying from adding a cachebuster GET arg to including 1 or more (usually all) of these headers:
pragma: no-cache
cache-control: no-store, no-cache, must-revalidate
expires:

Admittedly I have generated CSS from CGI scripts in the past, but that was only because I was generating the CSS file from randomly generated values (different on each page load).

(Reply to this)(Parent)


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…