Thus, the cap (Topi) is mentioned in the Hadith and we learn that in the blessed era of the Holy Prophet (Sallallahu alaihi wa sallam), caps were very common and specially for Salaat, turbans were also worn, as given in Sahih Bukhari:
Translation of Hadith: The great Tabi'ee Hadhrat Hasan Basri (May Allah be well pleased with him) says: Because of the heat, the Sahabah, would perform Sajdah on their caps and turbans and their hands would be in their sleeves.
(Sahih Bukhari, Vol. 1, Pg No. 56)
There is another Hadith, the Holy Prophet (Sallallahu alaihi wa sallam) was asked about the clothes of Ihram and He (Sallallahu alaihi wa sallam) said:
Translation of Hadith: You should not wear tunics (Kameez in Urdu), nor pajamas, neither turbans nor caps.....
(Sahih Bukhari, Vol. 1, Pg No. 248, Hadith No: 1838)