https://sap.github.io/spartacus-docs/server-side-rendering-optimization/

为什么要引入服务器端渲染优化?

Without SSR optimization, it is possible for the following to occur:

  • Pages do not render quickly enough, which leads to SSR using too much memory, and eventually it fails.

如果页面渲染不够快,可能会导致 SSR 使用了太多内存,最终导致渲染失败;

  • A response is not received in time, and an HTTP 500 error is returned.

无法按时接收到响应,只得返回 HTTP 500 错误给客户端。

Memory leaks are often the result of issues with the SSR implementation, while failover can happen when the SSR response is not cached.

SSR 实现中的 bug 通常会导致内存泄漏,而 SSR 响应如果不缓存下来,可能会导致故障。

启用 SSR 优化引擎的方式:

To enable the SSR optimization engine, use the NgExpressEngineDecorator decorator in your server.ts file. The following is an example:

import { ngExpressEngine as engine } from '@nguniversal/express-engine';
import { NgExpressEngineDecorator } from '@spartacus/setup/ssr';[...]const ngExpressEngine = NgExpressEngineDecorator.get(engine);[...]// In the app() functionserver.engine('html',ngExpressEngine({bootstrap: AppServerModule,})
);

SSR 优化引擎的参数

timeout

a number that indicates the amount of time (in milliseconds) during which the SSR server tries to render a page, before falling back to CSR.

该配置的单位是毫秒,代表 SSR 服务器在退化到使用客户端渲染之前,能够消耗用于渲染页面的时间。如果过了这个时间间隔,还未完成服务器端渲染,则返回 CSR 的 index.html 给客户端。该 index.html 不包含任何渲染好的 markup.

The CSR app (index.html) is served with a Cache-Control:no-store header.

这个 index.html 返回时带有 Cache-Control:no-store 头部。

As a result, it is not stored by the cache layer.

因此,index.html 不会存储在 Cache layer.

SSR pages do not contain this header because it is preferable to cache SSR pages.

服务器端页面不包含 Cache-Control:no-store 头部字段,因为 SSR 渲染好的页面需要被缓存。

In the background, the SSR server continues to render the SSR version of the page. Once this rendering finishes, the page is placed in a local cache to be returned the next time it is requested.

SSR 在后台持续渲染页面的服务器端版本。渲染结束后,存储到本地缓存里,下次被请求时,直接从缓存里返回。

By default, the server clears the page from its cache after returning it for the first time. It is assumed that you are using an additional layer to cache pages externally.

SAP Spartacus 3.3.0 版本服务器端渲染的优化相关推荐

  1. 手动安装 SAP Spartacus 3.3.0版本并启用服务器端渲染 SSR

    使用 ng new jerryssr 创建一个空的 Angular 项目: 确保项目创建成功. ng add @spartacus/schematics@latest --baseUrl https: ...

  2. 给基于SAP Spartacus 3.4.1 版本的 Storefront 添加对服务器端渲染的支持

    这个 Storefront 的本地地址:C:\Code\SPA\spa3.1\mystore31 基于的 SAP Spartacus 版本:大于 3.1.3,小于 4.0: 查看 package-lo ...

  3. SAP Spartacus CMS 页面加载逻辑和性能的优化

    https://github.com/SAP/spartacus/issues/3649 SAP Commerce Cloud CMS 页面加载的一些优化点: Payload of the CMS p ...

  4. 关于 SAP Spartacus OAuth 2.0 Resource Owner Password Flow 实现的一些讨论

    McAfee discovered that it is possible to retrieve a valid authentication token for a user, using an ...

  5. SAP Spartacus 2.1.0 加载homepage的逻辑

    2.1请求home page 的url: https://spartacus-dev2.eastus.cloudapp.azure.com:9002/occ/v2/electronics-spa/cm ...

  6. SAP Spartacus B2B 页面popover对话框的渲染逻辑

    读取config配置信息: 通过鼠标点击,和keyboardEvent事件不一样: componentFactoryResolver和viewContainer都是构造函数注入的属性: 这个conte ...

  7. SAP Spartacus 服务器端渲染调试的开发端版本

    我按照这篇文章手动安装 SAP Spartacus 3.3.0版本并启用服务器端渲染 SSR 的介绍,启用了 SAP Spartacus 服务器端渲染,并且按照SAP Spartacus服务器端渲染模 ...

  8. SAP UI渲染模式:客户端渲染 VS 服务器端渲染

    今年由于疫情原因,SAP一年一度的DKOM(Developer Kick-Off Meeting)切换成了线上模式,刚刚于昨天圆满落幕. 时间过得真快,去年的DKOM仿佛还历历在目:SAP成都研究院数 ...

  9. SAP Spartacus 服务器端渲染处理内存泄漏的准则

    开启服务器端渲染(SSR) 的 SAP Spartacus 实例,运行在 CCV2 Pod 里,当下列情况出现时,可能会造成 pod 的重启: resource allocation for SSR ...

最新文章

  1. awk 以列为域提取文件内容
  2. python的none是什么-python中的null与none有什么区别
  3. spring程序开发步骤
  4. postgresql 编码_上万份编码测试,大数据统计反映了公司在招聘时倾向的技能是什么...
  5. 只需2步,教你在Vue中设置登录验证拦截
  6. UVA-Parentheses Balance
  7. Hive2.0中HiveServer2的WEB UI界面
  8. 计算机网络试卷北理珠,北理工97级计算机网络终考试卷
  9. Maven:mirror和repository区别
  10. 财经大数据可视化Vdc平台_大数据时代-可视化数据分析平台必不可少
  11. 如何才能达到阿里 P7 水平 ?
  12. 将阿拉伯数字 翻译为 罗马数字
  13. 使用Qt进行音视频播放
  14. MATLAB基础图像处理算法
  15. linux开机到登陆的流程图,Linux开机自动登录root,并启动应用程序
  16. 电脑硬盘就一个c盘怎么分区,新电脑买回来只有一个c盘怎么分区
  17. Spring之自动装配
  18. 解决联想笔记本电脑经常突然休眠的问题
  19. logstash截取指定字符和grok的使用
  20. python 包用法,Python包的使用

热门文章

  1. tomcat8 安装|解决启动慢|进入管理|host-manager 403错误
  2. 弥勒市召开智慧城市建设规划设计征求意见会
  3. iOS之设置用户头像的圆角
  4. NETSH WINSOCK RESET这条命令的含义和作用?
  5. C++中如何去掉std::string对象的首尾空格
  6. 使用mysql自带工具mysqlslap测试数据库性能
  7. [转]使用DBX分析AIX 下的 CoreDump
  8. 总结:第一章~第五章
  9. linux中的opencv多版本共存切换的问题
  10. 洛谷P1527 [国家集训队] 矩阵乘法 [整体二分,二维树状数组]