当前位置:网站首页>Discussion on sending redundant API requests for Spartacus UI transfer state of SAP e-commerce cloud
Discussion on sending redundant API requests for Spartacus UI transfer state of SAP e-commerce cloud
2022-07-24 02:26:00 【Wang Zixi】
Angular Of TransferState Class makes server-side rendering (SSR) And pre rendering (Prerendered-SSR) Angular The application can use the data obtained from the server and render effectively in the browser .
If you are using SSR Or pre render application strategy , Then the process is roughly like this :
- Pre render or render the application on the server
- The browser gets the rendered HTML and CSS And display “ static state ” Applications
- Browser access 、 analysis 、 Explain and execute JavaScript
- Angular Application is booted , With the new “ Running ” Replace the entire DOM Trees
- Application initialized , Usually from a remote server or API get data
- Users interact with Applications
There are two problems with this scenario :
- DOM hydration The entire node tree will be replaced repeatedly and the application will be redrawn
- The application will repeatedly obtain the data that has been read theoretically , And because of SSR Or pre render the site policy and display it to the user
The first problem is that at present Angular Problems not solved in , however , There is already a solution to the second problem , This is what this article discusses Angular TransferState Mechanism .
Transfer State It's a strategy :
- Use SSR Or pre rendering strategy to get a complete rendering “ static state ” Data required by the application
- Serialized data , And use the initial documentation (HTML) Send data in response
- At application initialization , Parse serialized data at run time , Avoid redundant data acquisition
Technically speaking , Data is passed through JSON.stringify() Serialize and pass JSON.parse() analysis . however , Usually we don't need to worry about this , Because this is by Angular Medium TransferState Service is performed for us .
Even if the server is SSR Working in mode , stay Chrome browser network in , It can still be observed CMS OCC API Call to .



It's on products and cms Of ssrTransfer:
ConfigModule.withConfig({
state: {
ssrTransfer: {
keys: {
products: true,
cms: true
}
}
}
});

products: Indeed, it is not observed on the client OCC API Call to read product data .
cms: By default , Every time route When something changes ,Spartacus Will reload CMS The page data , Whether it already exists in ngrx store in .
Customers can modify configuration items :Spartacus config routing.loadStrategy: RouteLoadStrategy.ONCE To change this behavior .
The above logic is implemented in CmsPageGuard.shouldReload In the method .
边栏推荐
- ACM SIGIR 2022 | interpretation of selected papers of meituan technical team
- 【FPGA教程案例38】通信案例8——基于FPGA的串并-并串数据传输
- Writing of graph nodes that trigger different special effects during the day and at night in Tiktok
- Mysql数据库,分组函数篇
- Backward quantum cryptography migration! NIST announces 12 Partners
- 关于 SAP Fiori 应用的离线使用
- 奔走相告,行情与量化页面功能优化!股票量化分析工具QTYX-V2.4.5
- [Luogu] p1318 ponding area
- Qt开发串口通讯软件中的数据转换问题:读取时_QByteArray转string;发送时_数据格式;int转16进制格式string;string中截取字符;16进制数加法;string转ByteAr
- The combination sum of C language power deduction question 39. Backtracking method and traversal method
猜你喜欢

Enter cnpm -v and cnpm appears: the file c:\users\19457\appdata\roaming\npm\cnpm.ps1 cannot be loaded because running scripts is prohibited on this system.

What's new in the ranking list in July? This language is invincible?

Writing of graph nodes that trigger different special effects during the day and at night in Tiktok

Diablo king, analysis of low illumination image enhancement technology

【MySQL】字符集utf8mb4无法存储表情踩坑记录

wallys/WiFi6 MiniPCIe Module 2T2R2 × 2.4GHz 2x5GHz MT7915 MT7975

餐饮连锁门店重塑增长背后的数字化转型

程序员必备技能----断点调试(IDEA版)

Async await details & Promise

Chinese scientists have made new progress in high security quantum key distribution networks
随机推荐
网络协议详解 :UDP
The new red envelope cover platform can build the source code of the independent background of the sub station
[untitled]
Chinese scientists have made new progress in high security quantum key distribution networks
Ardunio - ULN2003 drive board and DC motor fan - control fan speed
Visual full link log tracking
College degree want to 0 basic programming after looking for a job feasible?
regular expression
Jina AI 联合Datawhale,发起学习项目!
ACM SIGIR 2022 | interpretation of selected papers of meituan technical team
2022.7.22 JS entry common data types and methods
新红包封面平台可搭建分站独立后台的源码
【数据集】——flyingthings3d光流部分数据集下载
BPG notes (III)
Data conversion problem in Qt development serial communication software: when reading_ Qbytearray to string; When sending_ Data format; Int to hexadecimal format string; Intercept characters in string
This article shows you how to use SQL to process weekly report data
[C language] preprocessing details
Build a CPU Simulator
【补题日记】[2022牛客暑期多校1]C-Grab the Seat
Go基础笔记_5_数组切片