On Sat, Aug 05, 2006 at 03:46:31PM +0300, Marius Feraru wrote: > Gavin Carr wrote: > > I do something similar to this but using attributes instead of methods in > > the autohandler: > > % if (my $css = $m->request_comp->attr_if_exists('css')) { > > <link rel="stylesheet" type="text/css" href="/css/<% $css %>" /> > > % } > > Slightly less flexible than yours, but lighter weight. > "Slightly" is quite inappropriate, "lighter" is OK. Why? Because you > miss almost all the flavor ("inheritance") by boiling it ;-)
I don't want inheritance. I want the ability to set a per-component css file. This does that. > > Another interesting trick is to setup an autohandler for the css files > NO! This is NOT "interesting", it's just like killing a mosquito using a > shotgun. All you'll get is hurting yourself and all the others around. > Rules of thumb: > 1) if it's static, DON'T use Mason to serve it; > 2) if it's to be cached, then set caching tags appropriately; > 3) if it's to be cached, then handle caching requests appropriately. > > > This sets a Cache-Control header allowing client-side caching of your > > css files for an hour, since they're typically completely static. > If it's static, breaks 1). So it's not... No, you misunderstand. Perhaps you should try thinking before firing off bombastic emails. The output is static, the input is not. The thread was in the context of "using mason for css lets you do various nice things with variables, conditionals etc." If was just a static file, then yes, we wouldn't use mason (doh!). > > <% $m->call_next %> > ^ adds an extra "\n", instead you could use: > % $m->call_next; OK. Happy to save one extra "\n". > > > <%init> > > $r->header_out( 'Cache-Control', 'public,max-age=3600' ); > > my $stat = File::stat::stat $m->current_comp->source_file; > > my $mtime = DateTime->from_epoch(epoch => $stat->mtime)->strftime("%a, %d > > %b %Y %H:%M:%S GMT"); > > $r->header_out( 'Last-Modified', $mtime ); > > </%init> > Completely breaks 3), refer to $r->meets_conditions (Apache::File). > 2) it's also broken even if barely taking into account just the facts > that you use header_out to set 'Last-Modified' and because you use > source_file's mtime. > For setting modification headers, use "set_last_modified", "set_etag" > AND "set_content_length". Also, using the "Vary" header properly will be > very helpful. > We settled it's not a static file, so using source_file's mtime is > wrong, as you don't use the resultant mtime composed from _all_ the > resources involved in generating the response. > Ah, and one more recommendation on this one: don't use DateTime for such > simple things, it's way too heavyweight for this purpose. Use > Apache::Util's parsedate/ht_time. I'm happy to see my suggestion improved, and would be delighted to see some code that would do the job better. Do you have some, or are you just a troll? Regards, Gavin ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users