23
If a module does not use templates, it is not cached and will not be affected in any way by the module-wide caching settings.
The root/header.php should not in any way be modified.
The only thing, which needs modification in some module pages is the ORDER of including header.php and setting the template to use.
If the page uses templates, it should include mainfile, then set the template to use, then include the root/header.php and then the code to fetch data in the database etc. etc. etc.
Also, any access restrictions etc. should go before the inclusion of header.php, but not too much data manipulation or database calls - otherwise you will lose the advantage of the caching.