Cavagnis was born in Bordogna, which today falls within the Commune of Roncobello, in the Diocese of Bergamo.
After a course in the Pontifical Roman Seminary, he received a doctorate in philosophy, theology, and in civil and canon law.
Pope Leo XIII named him professor of public ecclesiastical law in the Roman Seminary in 1880, a position which he retained for fifteen years, during which time he proved himself an eminent canonist, especially in all that related to the constitution of the Church and its relations with civil society.
He was appointed Consultor of the Sacred Congregations of Bishops and Regulars, of the Council, and of Studies; Consultor and Secretary of the Congregation of Extraordinary Ecclesiastical Affairs; Canonist of the Sacred Penitentiary; and member of the Commission for the Codification of Canon Law.
Austria, Spain, and Portugal honoured him with titles and distinctions, while the sovereign pontiff made him successively canon of several Roman basilicas, rector of the Roman Seminary, Domestic Prelate, and finally, on 18 April 1901, raised him to the cardinalate as Cardinal-Deacon of Santa Maria ad Martyres.