Angular 2 SpaTemplate how to remove server-side re

2019-09-15 18:36发布

问题:

I have created a GitHub repo that currently has two branches, master, and clean_state (The default Angular 2 SpaTemplate). I am looking to remove the server-side rendering while still keeping the application working in a similar way. I am working with Visual Studio 2017 Enterprise edition and this project is an Asp.Net Core 1.1 project.

I have never worked with this technology and only understand the basics of stripping this module from the project.

My question is what totally needs to be removed from the SpaTemplate to remove server-side rendering, and what features do I lose by doing this? I am not only asking what needs to change to turn off server-side rendering. What files need to be removed/changed to remove it completely from the project. I want to have a GitHub repo that I can clone that includes either a clean_state (server-side rendering) or a no_server (completely removed server-side rendering).

Will Hot Module loading still work? What are the performance differences? What are the performance differences on a small scale web app, 100-1000 views a month? What is the performance with or without server-side rendering with hundreds of requests per minute?

I understand the numbers given may or may not be totally accurate. Please be within reason when giving these statistics, as well if you're proposing something insane, provide linked evidence.

GitHub -Link to Repo - Please Fork and create pull-requests if you can help.

回答1:

To remove server side pre-rendering erase asp-prerender-module in Index.cshtml see here for the exact line details. Hot module replacement will continue to function. As for performance you'll see no noticeable changes with the amount of traffic your proposing. There are a few downsides to removing it.

Your SEO will decrease. Web crawlers don't load javascript so all they'll see is Loading.... Pre-rendering can also give the end user a perceived performance boost. The page can load very quickly because it's already been rendered. While the javascript files are still downloading.