MAGE-471: added check, which skips caching headers if messages should be printed on current page