Since Sass generates the CSS files, how about having it generate a
unique filename that one can put ExpiresDefault "now plus 1 year" on?
Then add a little helper function to use the correct css filename in
the templates, and voila: opt-in perfect caching with minimal
configuration and one function call (that is cacheable in
production).

Details:

Sass::Plugin.options[:perfect_caching] = true # Default false
Sass file: main.sass
CSS file: "main_[md5_checksum_of_contents].cache.css" instead of
"main.css"
Stale main_xxx.cache.css automatically deleted on update
Helper method: "sass_include_tag 'main'", checks on disk for the right
file to use and puts in the <link rel='stylesheet'
href='main_xxx.cache.css'>-tag, result cached in production (sure, put
in another config option)

In your apache config, add:

        ExpiresActive On
        <Files *.cache.*>
            ExpiresDefault "now plus 1 year"
        </Files>

and voila, your CSS is perfectly cached.

(then you can also rename your prototype.js (et al) -> prototype.
[version].cache.js as well, so using *.cache.* makes for easy cache
management, see how GWT generates files at the bottom of:
http://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebugging.html
)

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/haml?hl=en.

Reply via email to