SAP 电商云 Spartacus UI SSR 模式下发起的 CMS 请求讨论

简介: SAP 电商云 Spartacus UI SSR 模式下发起的 CMS 请求讨论

I create a storefront using Schematics based on version 3.4.5 and run it under SSR mode.

I access http://localhost:4000/ in browser.

Via Chrome dev tools I know that the source code of home page is generated by SSR server successfully.

However, even in SSR mode, I found the /cms/pages OCC API is still triggered from client side.

38.png

39.png

40.pnghere is log in SSR server, no CSR fallback occurs.

However in client side, I do find these three OCC API calls.

Is this behavior working as designed?


I add the following code in app.module.ts:

ConfigModule.withConfig({
  state: {
    ssrTransfer: {
      keys: {
        products: true,
        cms: true
      }
    }
  }
});

and I observe the following OCC API calls in Chrome dev tools when I access home page returned by SSR server:


no API for product data are found.


So my understanding is:


the API for product data in client side is considered as “unnecessary calls to the back end for the state” and avoided by SSR transfer state, right?

41.png也就是说,浏览器环境下的 Spartacus 应用不会再发起 product 请求。

For products - I guess the state was transferred from SSR to CSR.

结论

By default, Spartacus reloads CMS page data on every route change, regardless it has it already in ngrx state.

每次 Spartacus 发生 route change,即浏览器地址栏里的 url 发生变化时,都会重新加载 CMS page data.


However, customers can configure it differently via the Spartacus config routing.loadStrategy: RouteLoadStrategy.ONCE

It’s used in CmsPageGuard.shouldReload method.


客户可以通过修改 routing.loadStrategy 的值为 RouteLoadStrategy.ONCE 来更改这个行为。



41.png


38.png

目录
相关文章
|
1月前
|
前端开发 搜索推荐 JavaScript
Spartacus Cart item 点击了 remove 之后 HTTP Delete 请求的触发逻辑 - Adapter
Spartacus Cart item 点击了 remove 之后 HTTP Delete 请求的触发逻辑 - Adapter
|
1月前
|
开发者 UED
Spartacus cart 点了 remove 之后的 HTTP Delete 请求是怎么触发的
Spartacus cart 点了 remove 之后的 HTTP Delete 请求是怎么触发的
|
1月前
|
存储 消息中间件 搜索推荐
SAP Commerce Cloud Context Driven Services 的 clickStreamEvents HTTP 请求
SAP Commerce Cloud Context Driven Services 的 clickStreamEvents HTTP 请求
|
1月前
|
API 前端开发 JavaScript
Spartacus 中 saved cart 的 occ API 请求
Spartacus 中 saved cart 的 occ API 请求
Spartacus 中 saved cart 的 occ API 请求
|
1月前
|
测试技术 API
使用 jMeter 给 Spartacus SSR 发送 100 个并发的 SSR 请求,全部被 SSR 响应了
使用 jMeter 给 Spartacus SSR 发送 100 个并发的 SSR 请求,全部被 SSR 响应了
|
7月前
|
存储 JSON API
如何避免 Spartacus 重复发送 CMS page 请求
如何避免 Spartacus 重复发送 CMS page 请求
关于 Spartacus CMS 请求响应是否应该被 Transfer State 机制 cover 的问题
关于 Spartacus CMS 请求响应是否应该被 Transfer State 机制 cover 的问题
|
8月前
|
缓存 负载均衡 前端开发
SAP Spartacus 和 Sticky session 相关的话题
SAP Spartacus 和 Sticky session 相关的话题
|
8月前
|
存储
SAP Emarsys 和 SAP Spartacus 的集成
SAP Emarsys 和 SAP Spartacus 的集成
|
8月前
|
API 开发者
Google Tag Manager (GTM) 和 Adobe AEPL 在 SAP Spartacus 中的应用
Google Tag Manager (GTM) 和 Adobe AEPL 在 SAP Spartacus 中的应用