There were changes in Moodle 3.8 to the way Moodle compiles and serves js. Some 3rd party plugins that defined AMD modules a particular way that had worked up until 3.8 broke. The problem is avoided when not caching because first.js ( a big fat aggregation of all plugins js) is not involved. Its the aggregating of those poorly defined JS modules that causes the issue.
This tracker issue covers it:
https://tracker.moodle.org/browse/MDL-67327
This tracker issue covers it:
https://tracker.moodle.org/browse/MDL-67327