Menu

Clear script cache in AEM


At some point you may face the issue where your AEM page is not getting loaded and following errors getting printed in error log file.


Errors:

*ERROR* [182.75.136.107 [1589236795135] GET /content/jorvee/tools/en_us/gen-tool-10-10.html HTTP/1.1] com.day.cq.wcm.core.impl.WCMDeveloperModeFilter Error during include of SlingRequestPathInfo: path='/content/jorvee/tools/en_us/gen-tool-10-10/jcr:content', selectorString='null', extension='html', suffix='null'org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 60000/60000 ms

OR 

*ERROR* [0:0:0:0:0:0:0:1 [1531894023650] GET /content/we-retail/us/en/user/smartlist.html HTTP/1.1] com.day.cq.wcm.core.impl.WCMDeveloperModeFilter Error during include of SlingRequestPathInfo: path='/content/jorvee/tools/en_us/gen-tool-10-10/jcr:content', selectorString='null', extension='html', suffix='null'
org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: Identifier com.adobe.cq.wcm.core.components.models.Page cannot be correctly instantiated by the Use API


Resolution:

To solve this issue we need to clear the cached HTML and JS files from AEM.

Solution 1:


Browse the "Adobe Experience Manager Web Console Script Cache Status" http://localhost:4502/system/console/scriptcache
at the bottom of the page there is a "Clear Cache" button, click on the button to clear all the above listed cached scripts. You may also clear one by one if you doesn't want to clear all of them. To remove the individual script click on the remove button next to that script in right.

Adobe Experience Manager Web Console Script Cache Status
Adobe Experience Manager Web Console Script Cache Status

Solution 2:

Restart your AEM environment.

Hydroxychloroquine sulfate

Hydroxychloroquine sulfate is a solid crystal which doesn't have any color. Formula of Hydroxychloroquine is C18 H26 Cl N3 O. There is a huge rumor in market that this sulfate can be use to heal from the Coronavirus, which is not true. This medicine is to fight with Malaria. Till now there is no medical research proved and call to use the Hydroxychloroquine to treat the patients, but politicians are continuously talking and stocking this medicine all over world, without any fact check.

Although this medicine can be use to increase immune system of our body only.


References and Facts:


  1. Use of Hydroxychloroquine, Tablet Plaquenil
  2. The FDA’s emergency use authorization of chloroquine and hydroxychloroquine for COVID-19: Dangerous politics, not science
  3. Covid-19: six million doses of hydroxychloroquine donated to US despite lack of evidence
  4. Fact check: Trump wrongly claims FDA 'approved' drug chloroquine to treat the coronavirus

add versioning with clientlibs files in aem

In this article we wil see how to add or remove versioning with clientlibs files(like JavaScript and Cascading Style Sheet (CSS)) in aem? 
ACS AEM Commons provide a Versioned ClientLibs tool to make serve the clientlibs files(JS and CSS) with postfix with a unique id that is know as long TTLs. Everytime you update your any JS and CSS file that unique id get updated for that and because of that AEM server always serve the latest clientlibs files to browser. It also helps to invalidate the caching at CDN and dispatcher level and ensure every request get served with latest and updated version of clientlibs file.

To make our clientlibs files versionable we need to do the following configurations in AEM.
Install latest ACS AEM Commons. Donwload link. This will help us to allow CSS and JavaScript served via AEM ClientLibs to be cached client-side with long TTLs.

Create a Rewriter Configuration Node  

Under project config folder [/apps/<project name>/config/] create a node rewriter with node type sling:Folder.
Now under the rewriter node, create a node versioned-clientlibs of node type nt:unstructured and add the following highlighted properties on versioned-clientlibs.
You may refer the default configuration of tranformer and versioned-clientlibs under path /libs/cq/config/rewriter/default. 
After adding all configurations xml file of versioned-clientlibs will look like this. /apps/<project name>/config/rewriter/versioned-clientlibs/.content.xml


You may verify the changes in sling rewriter rules. http://localhost:4502/system/console/status-slingrewriter

versioned-clientlibs configuration in sling rewriter
versioned-clientlibs configuration in sling rewriter

 Apache Configuration

We need to now configure the Apache to send the right header to set a long TTL with clientlibs (JavaScript and CSS) files:
SetEnvIf Request_URI "(\.min)?\.[a-f0-9]+\.js" long_expires=true
SetEnvIf Request_URI "(\.min)?\.[a-f0-9]+\.css" long_expires=true
Header set Cache-Control max-age=2592000 env=long_expires 

How to disable this versioning or TTL from clientlibs files

To disable this feature, in AEM config manager we have a configuration called "ACS AEM Commons - Versioned Clientlibs Transformer Factory".

Note:
This re-writer does NOT support with

  • URIs embedded in CSS or JavaScript, including: background-images, web fonts, etc.
  • Relative URIs, e.g. etc/clientlibs/mysite/styles.css
  • URIs including a scheme, e.g. http://example.com/etc/clientlibs/mysite/styles.css and //example.com/etc/clientlibs/mysite/styles.css
  • URIs to non-AEM HtmlClientLibrary resources, e.g. /etc/designs/mysite.css
  • Tags contained in conditional comments.
  • ClientLibs included by Javascript (e.g. when leveraging the property channels)

References