aemslingclient-library

How does sling selectors work?


I am working on HTTP caching and to implement cache busting, I am using ACS Versioned ClientLibs. Now this works fine for js file when it is part of clientlib. For example <script src="/etc/designs/myapp/clientlibs/base.js"> works. But when I try to access an individual js within the library it doesnt work. For example <script src="/etc/designs/myapp/clientlibs/base/js/app1.js"> fails. The reason is the MD5 hash added as sling selector gets resolved when it is a clientlib js. But selector is not getting resolved when calling js individually. </base.hash.js> works but </base/js/app1.hash.js> fails.

How does AEM know to resolve selectors when calling clientlibs and doesnt do when calling individual js?

And the reason I need selectors to work specifically is, as per PageSpeed, most proxies donot cache static references with ? param. And asks to remove the query params. So I cant add query param for cache busting.


Solution

  • /etc/designs/myapp/clientlibs/base is a cq:ClientLibraryResource

    /etc/designs/myapp/clientlibs/base/js/app.js is a nt:file resource.

    There is no resource .../base/js/app this you can't request this resource w a selector (app.hash.js)