AEM Clientlib Versioning
Clientlib versioning allows CSS and javascript which is served by aem clientlibs to be cached for a very long time which in turn reduces the page load time of the website and improves performance. It has various benefits like -
- Longer TTL for cached client libraries.
- Improved web and site performance by reducing page load time.
- No more inconsistent data from the normal client library.
How it works -
- It uses Sling Rewriter to rewrite the client libraries and append a unique MD5 value at the end of the client library URL.
- This url get cache later.
- This MD5 value is unique for the code of ClientLibs.
- If there is a modification in code or ClientLibs, a new MD5 value will be generated and appended to the client library URL this allows it to recache.
Steps to create Clientlib version:
- Login to http://localhost:4502/crx/de/index.jsp
- Go to /apps/<your-project>/config
- Create a nt:unstructured folder by name it as a rewriter
- Go to /libs/cq/config/rewriter/default
- Copy the default node and paste it under your project config folder
Configure Apache to send the right headers so that it can be cached. Example
Versioned ClientLibs URL will look like this:
Note -
For loading versioned ClientLibs for the first time you need to restart AEM instance.
Validation -
· Navigate to http://localhost:4502/system/console/status-slingrewriter
· Search for resource path where versioned clientlibs is created /apps/<project-name>/config/rewriter/versioned-clientlib. If a resource path is found under the sling rewriter. That means the configuration is working fine.
Comments
Post a Comment