Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

How to use the "long cache" feature in HTML Library Manager?

paulr19803740
Level 1
Level 1

There is a "long cache" feature in the com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl which apparently has similar functionality to ACS Commons Versioned Clientlibs. However, I can't find any documentation on how it's supposed to work.

 

I've tried this out locally and when I set the "htmllibmanager.longcache.patterns" to "/.*;auto" it generates the clientlib include with a version string like so: /etc.clientlibs/company-name/clientlibs/clientlib-all.lc-1600281673684-lc.css

(note that I also needed to manually click "Invalidate Caches" in http://localhost:4503/libs/granite/ui/content/dumplibs.rebuild.html before this took effect).

 

However, since the cache key is set to "auto", it is automatically generated when this service restarts. In my mind that defeats the purpose since I don't want to restart the service every time I make an update to the CSS or JS in the clientlib. What am I missing? How is this feature supposed to be used so that it really mimics what ACS Commons Versioned Clientlibs is doing?

 

I saw a few people with the same question but no satisfactory answer yet:

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/adobe-granite-html-library...

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/adobe-granite-html-library...

 

cache ClientLibs
8 Replies
Singaiah_Chintalapudi
Community Advisor
Community Advisor

This looks like its related to client-side/browser caching. If you're looking for browser side caching, I would strongly recommend to use either Apache or CDN (this is recommended for easier maintenance) to pass the expiration headers for your client libraries.

 

If you can manage these configurations at Apache/CDN then you have more control over the expiration headers for other files i.e. images, documents as well.

 

Let me know whats your requirement?

 

Thanks,

Singaiah

paulr19803740
Level 1
Level 1
Yes, I get that, but in order to have far-future expires headers in Apache or the CDN I need to have a version string or hash of some sort on the clientlib include.
Singaiah_Chintalapudi
Community Advisor
Community Advisor
Why do you need a version string? You can define the expiry headers using path or file types.
Singaiah_Chintalapudi
Community Advisor
Community Advisor
If you need a some kind of hash then you would need to change configs all the time in Apache. Thats not true.
paulr19803740
Level 1
Level 1
Yeah, I can set expires headers using the path and file type. That's not a problem. My scenario is for clientlibs with CSS/JS that constantly change. So if new changes get pushed, how does it get invalidated? The point of the version string is that the browser/CDN knows that the file has changed and can then request the new file.
Singaiah_Chintalapudi
Community Advisor
Community Advisor
You have few options: 1. You'll have to leverage the ACS Commons versioned clientlibs or 2. Flush these clientlibs from Dispatcher/Akami (The user might or might not see the changes immediately) depends on the expiry headers.
paulr19803740
Level 1
Level 1
Yes, I'm aware of the alternatives. I would still like to see if anyone can answer my original question about the feature that exists OOTB in AEM.
paulr19803740
Level 1
Level 1
I don't understand why this was marked as the accepted solution. I appreciate the response but it did not address my actual question.