Comments (10)
'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.
fix it 3d589fc
from universal-starter.
@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.
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.
@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.
@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.
@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.
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.
@asadsahi yes, subscribe to #8
from universal-starter.
Thanks @Gorniv
from universal-starter.
Related Issues (20)
- Nodemon error HOT 1
- 'format:check command not working HOT 1
- Question. InlineStyleComponent HOT 3
- Prerender- state undefined Is this error message?
- Remove dependency from package.json
- Host application on Azure HOT 1
- Validation do not work
- window is not defined with DOMINO - Angular 9 HOT 1
- Home page is not rendering as ssr: Angular 9
- Error: Can't set headers after they are sent. at SendStream.headersAlreadySent
- *Question* Setting Dynamic Meta Tags with HTTP calls? HOT 1
- how to add absolute path for scss files
- Error: Can't set headers after they are sent to the client
- How can i deploy on firebase HOT 5
- Postscribe(use to add 3rd party script) is not working: Angular 9 Universal.
- Looks like unused variable. HOT 1
- Translate Service NullInjection problem while prerendering HOT 2
- Cannot read property 'start' of undefined at new EffectsRootModule HOT 1
- Is there a way to implement proxy when do SSR?
- Is there any update for angular 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from universal-starter.