需要解释Docpad持久性(Need explanation for Docpad persistence)

编程入门 行业动态 更新时间:2024-10-28 05:25:47
需要解释Docpad持久性(Need explanation for Docpad persistence)

我对Docpad中数据持久化的架构非常困惑。 从博客和论坛,我知道内存(和/或目录)用于生成的内容。 但Docpad的卖点之一是“完全基于文件”。 从它的声音,在Heroku或任何短暂的文件系统上托管它似乎不合逻辑。 任何人都可以给出一些解释/澄清吗?

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?

最满意答案

DocPad是下一代Web架构的基础。 这个思维导图展示了我们称之为完美的原因:

DocPad Architecture Vision http://d.pr/i/jmmZ+

工作流程如下:

进口商从任何来源引入数据,无论是本地文件系统,还是tumblr或mongo数据库。 这些被注入到DocPad内存数据库中 在生成时,DocPad将呈现需要呈现的内容,并将静态内容输出到out目录中 动态文档(在每个请求上重新呈现的文档)和动态能力(服务器扩展)现在能够利用内存数据库并执行高级酷的东西,如文件上传,联系表单,搜索页面,等等

从这个意义上讲,DocPad是下一代Web架构,具有静态站点生成功能以及动态站点生成功能。 DocPad与传统Web架构的区别在于,传统的Web架构会考虑内容并模板化各自的存在,而DocPad认为它们是相同的,并且只是通过扩展分开。 传统的Web体系结构在默认情况下也是动态的,静态站点生成通过缓存完成,而不是默认情况下静态的其他方式。

由于这种负载在内存数据库中的所有情况,我们正在遭受一些在生成和后代期间的性能增长的痛苦。 在这里讨论。 但是,没有任何东西无法用足够的时间和资源来修复。 无论如何,由于静态特性(更快的请求)以及异步特性(更快的代),DocPad仍将比传统的Web架构更快。

就如何处理文件上传而言:

如果您正在使用DocPad进行静态网站,那么您将在其他地方使用后端API服务器进行上传,并将数据作为单页应用程序样式加载到DocPad中。

如果您正在使用DocPad进行动态网站,您可以在像Heroku这样的服务器上托管DocPad,并扩展服务器以处理文件上传到目标,如Amazon S3,Dropbox或MongoDB等。 然后,您可以选择通过templateData作为链接公开文件,或将文件作为文件注入DocPad内存数据库。 您选择的是您是否只想引用上传或将其视为DocPad Universe中的头等公民(它获取自己的URL和页面)。

对于动态网站,我会说我真的采用静态网站+单页面应用程序方法。 您可以获得诸如响应式设计,离线支持,非常快速的用户体验等优势,无论采用哪种Web架构,您都无法通过动态站点方法来完成它。

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.

更多推荐

本文发布于:2023-07-30 08:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336684.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:持久性   Docpad   persistence   explanation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!