core: cache result of check if a specific module is enabled.
(cherry picked from commit 3793e75ee0254f83e9ff3b26240b5ed6f99868eb)