Runtime extension is not available: use" error after new package deployment



Hi Team,

After deploying new packages in the "author", I am getting the below error very often, when I try accessing the custom application pages:















Also, when I encounter the above error in my custom application pages, I get the same error while trying to access some of the AEM pages as well (like, "/welcome.html" or "/sites.html" or "/start.html"). In many instances, I am getting the same error in "publish" as well (after replicating the pages).

This was initially a showstopper, until I came up with a solution for this. After clearing the script cache (accessible through  <server>/system/console/scriptcache), the pages load fine.
















Now my question, I want to know the root cause for this issue, so that I can fix it on a permanent basis. This issue is absolutely erratic in nature.