CRM and CX Blogs by SAP
Stay up-to-date on the latest developments and product news about intelligent customer experience and CRM technologies through blog posts from SAP experts.
cancel
Showing results for 
Search instead for 
Did you mean: 
joris_quenee
Product and Topic Expert
Product and Topic Expert
3,261

Introduction

SAP Commerce Cloud platform doesn't integrate CDN solution. For small business, we have what we call Web Caching. This cache is limited up to 5GB and 120 IPOS. But for larger business, it is often necessary to invest in true CDN solution as Akamai or CloudFlare. 

CDN can server many purpose as

This article is focusing on proxy and static caching

 

EndPoints limitation

SAP Commerce Cloud Portal has a limitation on number of EndPoints it can support. Above 50 EndPoints, performance will be impacted drastically.

The solution is to setup CDN in upstream to act as proxy.

Capture d’écran 2024-01-29 à 16.26.45.png

Public domain name is pointing on CDN server. All user requests are going through CDN even if it is not cached. CDN is used as Proxy to have one EndPoint declaration in SAP Commerce Cloud Portal. This EndPoint should accepts only requests coming from CDN. IP Filtering can be setup in EndPoint to restrict access to out coming IP of CDN. 

CDN must inject X-Forwarded-Host HTTP header to inform SAP Commerce Cloud which website content should be rendered.

In Legacy Accelerator, this HTTP Header is captured by Tomcat. And in Composable Storefront / Headless, this HTTP Header is captured by NodeJS / SSR part.

 

Legacy Accelerator

In Legacy situation, we've to push customize Tomcat server.xml setting into SAP Commerce Cloud system. 

SAP Commerce Cloud is using server.xml.tmpl template file to generate sever.xml target file. You should first download server.xml.tmpl content from HAC by Groovy Script. Then, you have to update the content according the change suggest in below. And finally, you must encode the content in base64 to inject the new server.xml.tmpl into SAP Commerce Cloud deployment system.

properties / Cloud Portal

 

 

ccv2.file.override.70.content=<base64Encoding>
ccv2.file.override.70.path=/opt/startup/server.xml.tmpl

 

 

server.xml

 

 

className="org.apache.catalina.valves.RemoteIpValve"
hostHeader="x-forwarded-host"
portHeader="x-forwarded-port"
protocolHeader="x-forwarded-proto"

 

Then, it is necessary to customize CMSSiteFilter.java / cmsSiteFilter bean to include a logic for fetching domain name provided by Tomcat and matching this domain name with URL Patterns defined in CMSSite item.

currentdomain = httpRequest.getServerName();

At the end, domain mapping can be processed as we have direct public domain name request (URL Patterns).

Capture d’écran 2024-01-31 à 10.40.55.png

 

Composable Storefront

In Headless situation, we've nothing to configure. Composable Storefront is supporting natively X-Forwarded-Host HTTP header.

core-libs/setup/ssr/express-utils/express-request-origin.ts

 

 

// domain name provided by HTTP Header is taken when it has been set
export function getRequestOrigin(req: Request): string {
[...]
let forwardedHost = req.get('X-Forwarded-Host');
[...]
return `${req.protocol}://${forwardedHost}`;

 

 

server.ts

 

 

// here X-Forwarded-Host is treated by Angular system
server.engine(
    'html',
    ngExpressEngine({
      bootstrap: AppServerModule,
    })
  );

 

 

 

Tracking

Because CDN has been setup in upstream, SAP Commerce doesn't receive anymore user IP. And then OpenSearch log won't contain correct RemoteAddr. 

 

 

 

"loggerFqcn":"org.apache.logging.slf4j.Log4jLogger",
"contextMap":{"RemoteAddr":"[111.222.333.444] "

 

 

 

If you want to continue track user IP until SAP Commerce / Tomcat system, you've to setup X-Forwarded-For HTTP header in CDN system.

 

Conclusion

CDN integration can be a complex topic. We see here only small part on what CDN can do and how we can integrate with SAP Commerce Cloud. For more advance scenario, you can contact SAP Expert Services 

 

3 Comments
adamreisberg
Active Participant

@joris_quenee your technical posts over the last month (and some of the legacy CX Works documents) have been extremely helpful and informative. Thanks again!

baogang20
Discoverer
0 Kudos

@joris_quenee, thanks for this introduction, another question about CDN is that does the CDN would impact the personalization function if no special configuration in the CDN, that means using URL as the cache key in CDN. 

For example, user A access the home page and the cache key is /electronics-spa/en/USD/, if the content is cached by CDN, when user B access the home page, use the cached content directly, the personalization component for user B is missing or not?

 

joris_quenee
Product and Topic Expert
Product and Topic Expert

@baogang20 It is valid remark. Natively CMS OCC API is not supporting CDN caching. As you well understand, if you do that, you will lost personnalisation. To improve that, you can do a customization to expose user segment/profil on API URL to get a key useable by CDN.

However SSR caching is supported and it won't impact personalization feature. Then CSR rehydratation can fetch/load personalized content.