From: Joe W. <jo...@gm...> - 2010-01-29 15:50:35
|
Hi Rusty, > However I would like the PHP *arhictecture* where when the web server > gets a request for a static file named foo.xql, it says, "Hmm, that > looks like an XQuery file. Let me run it through the query processor > before I send it back tot he client." This is how eXist already treats requests for .xql files, out of the box. You're not saying it isn't, are you? > And when it gets a request for a > regular .html file it just sends it without bothering the database. I defer to Jim's suggestions on caching, but I do wonder if anyone has tested the extra 'load' on the eXist database for serving static files - html, js, css, etc. At what point does this cause a bottleneck? > Extra bonus points if the server can respond to a request for foo.html > with either foo.html or foo.xql depending on which one exists. Sounds like a perfect job for URL rewriting. Insert this in the relevant controller.xql: if (ends-with($exist:resource, '.html)) then if (exists(doc(concat($exist:controller, $exist:root, $exist:path)))) then urlrewrite:ignore() else if (util:binary-doc-available(replace(concat($exist:controller, $exist:root, $exist:path), '.html$', '.xql'))) then urlrewrite:forward(replace(concat($exist:controller, $exist:root, $exist:path), '.html$', '.xql')) Note that I've used shorthand urlrewrite:ignore() and urlrewrite:forward() instead of the full XML dispatch elements. > 3. Easier to start with a bunch of static files and slowly convert > them over to database-driven. Absolutely - makes sense! Joe |