How can we add build time of clientlib.miin.js files inside it.
For example inside clientlib.min.js and clientlib.min.css we want below lines
JS
window.build = "Sun Sep 06 2018 ";
CSS
/*! Build: "Sun Sep 06 2018 */
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
There is no OOTB way to update timestamp for JS or CSS.
But you can add a JCR Event listener which will execute whenever css or js file is created/modify under /etc/design/.... and delete corresponding minified file in /var/ folder if available it will make sure the file is always latest.
Or alternative you can update timestamp as soon as there is new update in /var/ folder
Views
Replies
Total Likes
There is no AEM specific functionality that will let you do this. To get a time stamp into a JS or CSS, you need to add custom app logic.
Views
Replies
Total Likes
So is there a way to check that clientlibs added to the page is of latest build and not cached?
As we include clientlibs using categories and page source have something like this
/etc/clientlibs/clientlibs.min.css
So how can we check if its of latest build or old build
Views
Replies
Total Likes
Have you looked at Versioned ClientLibs?
Views
Replies
Total Likes
Hi,
There is no OOTB way to update timestamp for JS or CSS.
But you can add a JCR Event listener which will execute whenever css or js file is created/modify under /etc/design/.... and delete corresponding minified file in /var/ folder if available it will make sure the file is always latest.
Or alternative you can update timestamp as soon as there is new update in /var/ folder
Views
Replies
Total Likes
Is there a way we can read maven timestamp value inside js and css files.
In JSP we can do as per below link
How to display maven project version in your webapp | Vineet Manohar's blog
But same doesn't work for js and css as replace <token>PROJECT_VERSION</token> happens for JSP file only.
Views
Replies
Total Likes
yes, you can get timestamp in maven Stamping Version Number and Build Time in a Properties File with Maven - DZone Java
You can try to execute a java program in maven build phase and try to do normal file read and write with replace token.
3 ways to run Java main from Maven | Vineet Manohar's blog
Views
Replies
Total Likes
Thats fine but I need the value in js and css file , not in Java file
Views
Replies
Total Likes
I meant to say Instead of running replace token plugin You can run java executable plugin in maven build and read your js and css file in that java program and append timestamp in css and js file using java code.
Views
Replies
Total Likes
I would strongly recommend this: Versioned ClientLibs
Views
Replies
Total Likes
Views
Likes
Replies