During the Tang and Song Dynasties, Shaxi, as an ancient town in Nanzhao and Dali, played an active role. As we all know, Buddhism has a deep influence on Nanzhao and Dali, which makes Nanzhao and Dali culture have a strong religious color. Shaxi was one of the witnesses of the spread of Buddhist culture at that time, and the grottoes excavated during Nanzhao and Dali periods in Shahe area of China were the best illustration. That is to say, in the Tang and Song Dynasties, Shaxi flourished because it was the only way for Nanzhao and Dali to reach Shadengjing and Shi Zhongshan Grottoes, and the land terminal on the ancient road of economic and cultural exchange between Tang and Tubo.