Imam Dhahabi rahimahullah said:
“I say: this Imam [Shafi’ee] with his excess in intelligence and vast knowledge used to take what would strengthen his memory.
Haroon ibn Sa’eed al-Ayla said: Shafi’ee said to us: “I took frankincense for one year for memory and the outcome was that I threw out blood (vomiting) for one year” [Siyar ‘Alam an-Nubala (10/45-46)]
It is authentic that Imam Shafi’ee rahimahullah took frankincense. It is reported in Adaab ash-Shafi’ee wa Manaqibuhu of Ibn Abi Hatim (pg. 245) with a Saheeh chain]
It seems that the best thing is to have it in the early morning on an empty stomach.
It is mentioned about the Spanish Scholar Abdul-Malik ibn Habeeb rahimahullah:
“[Abdul Malik] Ibn Habeeb used to have a bottle which he melted frankincense and honey in it. He used to drink it every morning on an empty stomach” [Ad-Dibaaj al-Mathhab (pg. 255)]
There are some other narrations from the Salaf that mention consuming franincense on an empty stomach, but the narrations are weak in Jami’ Akhlaaq ar-Raawi of Khateeb al-Baghdaadi (no. 1797,1799,1800)
And Allah Knows Best
Faisal Ibn Abdul Qaadir Ibn Hassan
Abu Sulaymaan