Topic: Dynamic CSS & Performance.

I have a need to one fairly large chunk of dynamic CSS. I'm aware there are various variations on the same separate controller/route system out there but from my understand of rails they're taking the fairly massive performance hit of an entire new rails process just to generate a CSS sheet.

I'm tempted to just dump it in the layout head but I'd like to keep it in a separate file if possible while being part of the same request so it's got access to instance variables etc. Isn't there some way with routes alone of getting Erb processed in a .css? The other option I guess is to move to edge rails where .xyz.erb is supported but I'd rather not for something that's going production in a few months.

Re: Dynamic CSS & Performance.

In edge rails the "rhtml" extension was simply changed to "erb" to make it more generic. I don't see why this would effect the performance of a dynamic CSS file.

Anyway, have you see this article on doing dynamic css?

As for improving performance, how about caching the generated CSS?

Railscasts - Free Ruby on Rails Screencasts

Re: Dynamic CSS & Performance.

More generic but you can also do .js.erb or .css.erb. Caching is half the battle but that method you pointed to is exactly what I"m talking about - it's a totally seperate request, performance wise it's the same as a component.

Re: Dynamic CSS & Performance.

mossy wrote:

More generic but you can also do .js.erb or .css.erb.

Interesting. I haven't seen the use of the double extension before. Although I don't see how it will help, it still requires a separate request.

mossy wrote:

Caching is half the battle but that method you pointed to is exactly what I"m talking about - it's a totally seperate request, performance wise it's the same as a component.

If you do Page Caching it shouldn't require a separate rails request - page caching is all handled by the web server and Rails isn't even involved (once the cache is generated).

Railscasts - Free Ruby on Rails Screencasts