Such municipalities may regulate, to such extent as to safeguard against the spread of conflagration, the thickness of the outside or fire walls of all buildings to be constructed within fire limits, and may reasonably regulate partition walls in buildings, where the regulation is proper to prevent the spread of fire.