Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does pre-rendering works?

Tags:

angular

The following is my current understanding of prerendering. Please correct me if I am wrong.

Imagine I have an Angular 7 application dashboard gated behind a login page. I will use angular universal (or other tools) to prerender login page and dashboard page (just a shell with loader), which will live with rest of my app as login/index.html and dashboard/index.html.

If users go to /login or /dashboard page, Nginx will check if cookie. If cookie says the user is logged in, Nginx will serve dashboard/index.html, otherwise, Nginx will serve login/index.html

Is the above correct?

Also, I have two questions:

  1. What if someone is not using Nginx and just using S3? How will they handle the above scenario without cookie access?

  2. What if someone goes to the unknown router? Say /not-found-route? How do you show a 404 page using prerendering?

like image 236
asdasd Avatar asked May 05 '19 21:05

asdasd


People also ask

What is pre-rendering in editing?

Pre-rendering creates a full quality version of a composite shot or video asset, providing faster performance. This is particularly useful when using embedded composite shots or using composite shots on the editor, as you can maintain fast performance regardless of the complexity of the timelines involved.

What does pre render do in After Effects?

When you Pre-render, After Effects will render the selected comp elements as a lossless movie and automatically replace them with the rendered file in your comp, often saving you significant rendering time for the final output.

What is pre-rendering in web development?

With prerendering, the content is prefetched and then rendered in the background by the browser as if the content had been rendered into an invisible separate tab.

What is the difference between real time rendering and pre-rendering?

Pre-rendering is the process in which video footage is not rendered in real-time by the hardware that is outputting or playing back the video. Instead, the video is a recording of footage that was previously rendered on different equipment (typically one that is more powerful than the hardware used for playback).


1 Answers

  1. If we are talking about using Anguar on your server only nobody can use something else that you didn't provide. I.e. if you use Nginx everyone else is going to use it either.

If that's about deploying on another server it should have access to the cookies. (However, I'm not sure if that's right, since I can make any cookie myself and provide you with it. You should be checking with your Backend this cookie).

  1. I guess that there is no way of knowing which routes are known for your app before loading but defining them in hard code way (which is a whole pain in the app with tons of routes).

The prerendered shell is just for showing a small part of UI while the actual app is being loaded. Then it's being replaced with the real app. Routes and guards etc. start working and Angular app takes care of anything else.

Also, I'm sure for 99% that any information that you need to hide from unauthorised user is being fetched from the server will have to pass your Angular's guards and Backend's auth checks.

  1. As far as I remember the prerendered "shell" is not defined for a specific route and there is no need to point it to any. Because, it just shows a loader (or anything else you want to indicate) then app is loaded an it works as if there were no shell.
like image 62
Sergey Avatar answered Nov 15 '22 04:11

Sergey