This paper demonstrates a topological meaning of quandle cocycle invariants of links with respect to finite connected quandles X, from a perspective of homotopy theory: Specifically, for any prime ℓ which does not divide the type of X, the ℓ-torsion of this invariants is equal to a sum of the colouring polynomial and a Z-equivariant part of the Dijkgraaf-Witten invariant of a cyclic branched covering space. Moreover, our homotopical approach involves application of computing some third homology groups and second homotopy groups of the classifying spaces of quandles, from results of group cohomology.