Expand my Community achievements bar.

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

Avatar

Level 2

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...

 

8 Replies

Avatar

Level 9

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

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.
Why do you need a version string? You can define the expiry headers using path or file types.
If you need a some kind of hash then you would need to change configs all the time in Apache. Thats not true.
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.
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.
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.
I don't understand why this was marked as the accepted solution. I appreciate the response but it did not address my actual question.