I am pretty confused with the architecture behind how data is persisted in Docpad. From blogs and forums, I got to know in-memory (and/or out directory) is used for generated contents. But one of the selling points of Docpad is "completely file based". From the sound of it, hosting it on Heroku or any ephemeral file system doesn't seem logical. Can anyone give some explanation/clarification?
-
The reason you would host it on a server like Heroku or some other server that has Node.js support is in case you have dynamic data in your website. DocPad can be completely static, on the other hand it can be completely dynamic. Or it can be both of them. But if anything on your website is dynamic or you need your website to regenerate from time to time then you need a server with Node.js support. Does that answer your question? If yes say so so I can put it in an answer. :) – greduan Aug 02 '13 at 16:47
-
Thanks for the answer. I forgot to mention about file upload. How does Docpad handle it in Heroku's ephemeral file system? Ephemeral file system doesn't write anything permanently. Sorry I'm still a bit confused with the "completely file based" from Docpad website. – 1001b Aug 02 '13 at 23:33
-
You might want to understand what a static website is first. That's what DocPad is, a static website *generator*. It generates a static website which you can deploy anywhere. Basically the content doesn't change, it is always served the same way, this makes it a way faster way to serve websites, since there's no server side logic going on. The idea of "completely file based" means that there's no database going on in the server. – greduan Aug 03 '13 at 01:39
-
1Thx again. I think Docpad is suffering "identity crisis". Is it a web application framework or simply a website generator for non-programmgers? If this is about serving static contents (in bloody truth nothing is static:(), what's the draw of streamlining "designers and developers"? My impression of developer is someone that writes back end logic code?? In my first experiment, Docpad is heavy. I can see it will soon hit by some performance issue. – 1001b Aug 03 '13 at 02:33
2 Answers
DocPad is pitched as a next generation web architecture. This mindmap showcases why we call it that perfectly:
DocPad Architecture Vision http://d.pr/i/jmmZ+
The workflow being like so:
- Importers bring data in, from any source, be it the local file system, or tumblr, or mongo database.
- These get injected into the DocPad in-memory database
- At generation time, DocPad will then render what needs to be rendered, and output static content into the out directory
- Dynamic documents (documents that re-render on each request) and dynamic abilities (server extensions) are now able to make use of the in memory database and perform advanced cool stuff like file uploads, contact forms, search pages, whatever
In that sense, DocPad is a next generation web architecture that has static site generation abilities, as well as dynamic site generation abilities. What separates DocPad from traditional web architectures, is that traditional web architectures consider the content and templating separate beings, where DocPad considers them the same and just separated by their extension. Traditional web architectures also are dynamic by defaults, with static site generation accomplished via caching, rather than the other way round of being static by default.
Because of this load everything in the in-memory database situation, we are suffering some from growing pains with performance during generation and post-generation. Discussion here. However there is nothing there that can't be fixed with enough time and resources. Regardless of this, DocPad will still be faster than your traditional web architecture due to the static nature (faster requests) as well as the asynchronous nature (faster generations).
In terms of how you would handle file uploads:
If you are doing a static website with DocPad, you would have a backend API server somewhere else that you would do the upload too and load the data into DocPad as a single page application style.
If you are doing a dynamic website with DocPad, you would host DocPad on a server like Heroku, and extend the server to handle the file upload to a destination like Amazon S3, Dropbox, or into MongoDB or the like. You can then choose to expose the file via templateData as a link, or inject the file into the DocPad in-memory database as a file. Which one you chose is whether or not you just want to reference the upload or treat it as a first class citizen in the DocPad universe (it gets it's own URL and page).
For dynamic sites, I would say I really go with the static site + single page application approach. You get benefits like responsive design, offline support, really fast UX which without doing it that way, you struggle a bit accomplishing it with the dynamic site approach regardless of which web architecture you build it on.

- 47,113
- 32
- 131
- 182
Well, I can't top off Benjamin's excellent explaination, but if you want a TLDR explaination:
docpad is used to (biggest-use-case) generate STATIC websites, a-la github pages or old websites of 1990s. You can write your pages in whatever you like (Jade, eco, coffeescript, etc) and it will compile the pages and output HTML files. Think of it as a "Compile-once-server-forever" thing.
On the other hand, if you want Dynamic content on your site, you'd like to use Nodejs for pulling in the dynamic data from other sites, or generating it on the fly.
As for your concern about Heroku's ephemeral file system, (I don't know exactly how what works) you can use Amazon's S3 for storage. Check out this

- 1
- 1

- 18,961
- 8
- 72
- 100