Reference AEM as Cloud service versioned clientlibs in non-AEM pages like Magento | Community
Skip to main content
rampai
Community Advisor
Community Advisor
December 19, 2023
Solved

Reference AEM as Cloud service versioned clientlibs in non-AEM pages like Magento

  • December 19, 2023
  • 1 reply
  • 847 views

Hi All,

 

Is there a way to reuse AEM client-library with the versioning enabled in non-AEM pages like Magento?

 

This is a common use-case where we want to reuse the header/footer from AEM and show in external systems but the challenge has been to get the Client-library working. Some legacy implementations that I have seen use the Client-library path without the versioning identifier but this creates a caching issue every time there is an update in the Client-library code.

 

e.g. Right now, in Magento we need to hard-code the reference: /etc.clientlibs/site/components/header/v1/header/clientlibs.min.js

 

Instead, what's needed is something that works within AEM itself like 

/etc.clientlibs/site/components/header/v1/header/clientlibs.lc-c8983e582efc9345b4qoi89499f98b-lc.min.js and this identifier should be auto-updated every time there's a change within AEM.

 

Any recommendations on how to achieve this?

 

Thanks,

Ram

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi @rampai 
Its look like you need the exact references.

But if you can disabled the browser/CDN cache for /etc.clientlibs/site/components/header/v1/header/clientlibs.min.js , I think this will work as well.

I believe with every cloud deployment all the cache(dispatcher, don't know about the Adobe CDN) deleted anyways.

 

Otherwise you have to expose clientlibs path from AEM as a data-attribute in the header/footer and then it can be loaded by external system

1 reply

arunpatidar
Community Advisor
Community Advisor
December 19, 2023

Hi @rampai 
You can either add your own cache buster like /etc.clientlibs/site/components/header/v1/header/clientlibs.lc-aem-magneto-mmhhddmmyyyy-lc.min.js.
where mmhhddmmyyyy can be aligned with AEM releases.

Another approach could be checking the bundle version/package version and adding to as a data arribute in header and then use that to load the js

/etc.clientlibs/site/components/header/v1/header/clientlibs.lc-<package-version>-lc.min.js.

Arun Patidar
rampai
Community Advisor
rampaiCommunity AdvisorAuthor
Community Advisor
December 20, 2023

Thank you @arunpatidar.

 

If I append an epoch string to the client-library it starts giving a 404. Problem is that random selector is not working in this case.

 

Regards,

Ram

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
December 20, 2023

Hi @rampai 
Its look like you need the exact references.

But if you can disabled the browser/CDN cache for /etc.clientlibs/site/components/header/v1/header/clientlibs.min.js , I think this will work as well.

I believe with every cloud deployment all the cache(dispatcher, don't know about the Adobe CDN) deleted anyways.

 

Otherwise you have to expose clientlibs path from AEM as a data-attribute in the header/footer and then it can be loaded by external system

Arun Patidar