Fix generating the cache in production environment

Marking the classes for reload works only when cache_classes are set to false.
Otherwise some strange errors when loading the controllers again might occur.