MDL-40475 add alternative component cache location

This also moves the define for MOODLE_INTERNAL because some subplugins.php use it which was killing component caching.