共计 2387 个字符,预计需要花费 6 分钟才能阅读完成。
当我拜访本地启动的 SAP Spartacus Storefront 时,在 Chrome 开发者工具里察看到总共 23 个 OCC API 调用:
http://localhost:4200/electro…
这 23 个 OCC API 调用从性能上能够分成三组:
第一组:蕴含一个申请
/occ/v2/electronics-spa/cms/pages?lang=en&curr=USD
Cache-Control in request headers: no-cache
客户端 HTTP 申请 cache-control 的值 为 no-cache,通知服务器,在发送响应给客户端之前,先进行缓存有效性验证 (cache validation)
服务器返回的响应头部字段 Cache-Control 的值:private
依据上面这篇文档,带有 cache-control:private 的响应,不应该在 CDN 里缓存。
在该 pages OCC API 调用完结之后,其余 22 个 OCC API 能力触发。
第二组:蕴含五个申请
(1) /occ/v2/electronics-spa/languages?lang=en&curr=USD
request header:Cache-Control: no-cache
response header:public, max-age=1800
(2) /occ/v2/electronics-spa/currencies?lang=en&curr=USD
request header:Cache-Control: no-cache
response header:public, max-age=1800
(3) /occ/v2/electronics-spa/cms/components?fields=DEFAULT¤tPage=0&pageSize=26&componentIds=AllBrandsCategoryLink%2CCanonBrandCategoryLink%2CSonyBrandCategoryLink%2CKodakBrandCategoryLink%2CSamsungBrandCategoryLink%2CToshibaBrandCategoryLink%2CFujifilmBrandCategoryLink%2CKingstonBrandCategoryLink%2CIciduBrandCategoryLink%2CTDKBrandCategoryLink%2CSweexBrandCategoryLink%2CDigitalCamerasCategoryLink%2CDigitalCompactsCategoryLink%2CDigitalSLRCategoryLink%2CFilmCamerasCategoryLink%2CHandheldCamcordersCategoryLink%2CWebcamsCategoryLink%2CCameraAccessoriesCategoryLink%2CCamerasFlashesCategoryLink%2CTripodsCategoryLink%2CCameraLensesCategoryLink%2CFlashMemoryCategoryLink%2CPowerSuppliesCategoryLink%2CColourFilmsCategoryLink%2CBlackAndWhiteFilmsCategoryLink%2CBlankVideotapesCategoryLink&lang=en&curr=USD
request header:Cache-Control: no-cache
response header:private
(4) /occ/v2/electronics-spa/cms/components?fields=DEFAULT¤tPage=0&pageSize=8&componentIds=AboutSAPCommerceLink%2CFAQLink%2CVisitSAPLink%2CContactUsLink%2CAgileCommerceBlogLink%2CLinkedInLink%2CFacebookLink%2CTwitterLink&lang=en&curr=USD
request header:Cache-Control: no-cache
response header:private
(5) /occ/v2/electronics-spa/users/anonymous/consenttemplates?lang=en&curr=USD
request header:Cache-Control: no-cache
response header:no-cache, no-store, max-age=0, must-revalidate
第三组:蕴含 17 个申请
/occ/v2/electronics-spa/products/<product-code>?fields=code,configurable,configuratorType,name,summary,price(formattedValue),images(DEFAULT,galleryIndex),baseProduct&lang=en&curr=USD
request header:Cache-Control: no-cache
response header:private, max-age=120
咱们能够在 Chrome 开发者工具里很容易察看到浏览器里这些 OCC API 并发申请的排队状况。
依据 Google Chrome 的帮忙文档,这种 Queueing 和 Stalled 的排队状况,产生在客户端。
更多 Jerry 的原创文章,尽在:” 汪子熙 ”: