On Wed, 21 Jun 2017 12:08:28 GMT, Martin Tschierschke wrote:

I know there has been similar questions maybe someone can point me to an answer.

My idea wish is to get the theoretically fastest possible content delivery for HTML.


If someone is making a request for example for a news posted, the id of the news gets extracted from the url,
the database is requested to deliver the records necessary to render the page, the page is rendered and delivered.

In an rails environment especially the rendering might be so slow, that caching is needed, so an caching layer is included.

update => db in rails
request => db => cache? cached : rendering

With vibe, this gets easier, you don't need the cache:
update => db
request => db => rendering

But most of our site is quite static, with only a few dozen changes per day, so I want to change this order:

Rendering before the request.

A task is looking for updates in the DB or is triggered in an other way. An often requested content, like the home page, the first news index or the single news pages are rendered (with vibe) in advance and stored in the file system to be delivered directly. Or maybe storing parts of them in/with memcached.

update => db + content to files
request => from file only (some requests!)

There are parts like the local search, where this is not possible.

So my question is: How to call a registered / routed actions in vibe.d to render the output to a file.

I know a work around would be to call vibe.d with curl and save the result.

It should be possible to do this using the createTestHTTPServerRequest and createTestHTTPServerResponse functions. Those can be called with arbitrary input/output streams, so that the response can be re-routed to a file. URLRouter.handleRequest would then just have to be called with the returned request/response objects to execute the route handler.