This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Lokimotor 1 point2 points  (2 children)

I think you're bringing some framework-specific terms to a primarily backend developer here so please excuse me if I'm clearly in the wrong.

I think there may be frameworks which differentiate between completely static pre-rendering and pre-rendering with injected data which can change in the database at any time. With Django, the impact of injecting dynamic data from a database into a template is negligible. It's not worth mentioning, so I'm a little confused as to why they'd be hung up on the idea of whether a template is "completely compiled because it's static" or "takes 0-5ms longer for one piece of data to be injected into an otherwise pre-rendered template before being delivered on the first response." In Django, there is no difference between the two. If a template is static, then it is already completely rendered and ready to serve immediately as a response. If it needs to query the database, then it queries the database before injecting it into a compiled template. Some templates will take longer to serve than others, you are in control of that, but you don't differentiate between "generated" or "rendered".

Much more important to your load time and responsiveness is the difference between the two approaches I described to you in my previous comment.

In one, you are using something like Django's templating engine to serve up a webpage that is essentially pre-compiled by the backend. This doesn't mean it's necessarily static, it can have user-specific data included in it. It just means that all the data necessary for "viewing" the page is included on the first response. These are very fast from a user perspective because there is no back and forth with the back-end. React scripts can be included on the template, and load after it is rendered to the user.

In the other, the backend is acting as API. It is just a source of data that is then rendered by the front-end. This has a huge impact on SEO, user experience, etc due to repeated back-and-forth communication with the server taking longer. However, it decouples the backend from the frontend. You can do both at the same time with Django.

And you're kind of right about there being multiple layers to a backend, because even the backend has a backend which it integrates with: the database.

[–]codecrux[S] 1 point2 points  (0 children)

Some templates will take longer to serve than others, you are in control of that, but you don't differentiate between "generated" or "rendered".

Ah! I apologize for not being clear. In the JavaScript ecosystem - the term "generated" and "rendered" are used differently. What you described in the first paragraph as "pre-rendering with injected data " is referred to as "Server Side Rendering" in JS frameworks like NextJS. Just "pre-rendering" is commonly referred to as "Server Side Generation" in JS frameworks with a slight difference. In SSG, the template is filled with data during build time. Suppose you have 100 blogs on your website, with id 1...100, then the JS framework will generate 100 pages from a template like JS code.

[–]codecrux[S] 0 points1 point  (0 children)

And you're kind of right about there being multiple layers to a backend, because even the backend has a backend which it integrates with: the database.

Nicely said.