Coder Social home page Coder Social logo

Comments (10)

Gorniv avatar Gorniv commented on May 18, 2024 1

'node server.js' dont use prerender. Prerender is alternative for use static with seo and angular.
Look https://github.com/AngularClass/universal-sitegen

from universal-starter.

Gorniv avatar Gorniv commented on May 18, 2024

fix it 3d589fc

from universal-starter.

asadsahi avatar asadsahi commented on May 18, 2024

@Gorniv thank, it has indeed. What pattern do you reckon about generating these pre-rendered pages? during development or production. Hardcoding URL suggest that we need to host the url because if pages use any http request to get data, pre-render fails since it cannot find any site on that url yet.

When deployed on production, url will exist so pre-render can get the data. Also have you given any thoughts on caching strategy of dynamic or pre-renderd page? what are the options?

from universal-starter.

Gorniv avatar Gorniv commented on May 18, 2024

Prerender build pages with all content one time. Value of ORIGIN_URL depends on your page and logic. You use angular with current ORIGIN_URL of web browser page after prerender. I think that prerender page needs a very simple site like landing. I use dynamic server-side render with node.

from universal-starter.

asadsahi avatar asadsahi commented on May 18, 2024

@Gorniv in your case you aren't using ORIGIN_URL during SSR/Prerender but in my case I get some data fetched from server when application initialises, therefore in order to build these pre-rendered pages, I have to make a working ORIGIN_URL. And it works if I have ORIGIN_URL serving the data.

Having site pre-rendered already for all urls surely boost performance since there isn't any server side execution.

Does following code works for both pre-rendering and dynamic rendering?

 const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require(`./dist/server/main.bundle`);
      this.app.engine('html', ngExpressEngine({
        bootstrap: AppServerModuleNgFactory,
        providers: [
          provideModuleMap(LAZY_MODULE_MAP)
        ]
      }));

Does it try to get pre-render page and then falls back to dynamic rendering?

from universal-starter.

Gorniv avatar Gorniv commented on May 18, 2024

@asadsahi if you want to use prerender and dynamic rendering you need change server.ts. Server.ts need use a different route for prerendering and dynamic route. I will think about add example in the repository.
I add environment in prerender.ts

from universal-starter.

asadsahi avatar asadsahi commented on May 18, 2024

@Gorniv If you don't generate prerender pages then existing setup does dynamic rendering. I am not using 100% your server.ts and prerender.ts but I think ngExpressEngine falls back to dynamic rendering if prerender pages aren't found.

Your setup matches quite close to angular-universal starter and thats what I am following and just proved the concept described above.

from universal-starter.

asadsahi avatar asadsahi commented on May 18, 2024

Ahh I see, so does that mean with current setup it always use dynamic-rendering? pre-render pages are only if someone wants to use static pages?

from universal-starter.

Gorniv avatar Gorniv commented on May 18, 2024

@asadsahi yes, subscribe to #8

from universal-starter.

asadsahi avatar asadsahi commented on May 18, 2024

Thanks @Gorniv

from universal-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.