In a recent Letter [T. Dornheim et al., Phys. Rev. Lett. 121, 255001 (2018)] we have presented the first ab initio results for the dynamic structure factor S(q, ω) of the uniform electron gas for conditions ranging from the warm dense matter regime to the strongly correlated electron liquid. This was achieved on the basis of exact path integral Monte Carlo data by stochastically sampling the dynamic local field correction G(q, ω). In this paper, we introduce in detail this new reconstruction method and provide several practical demonstrations. Moreover, we thoroughly investigate the associated imaginary-time density-density correlation function F (q, τ ). The latter also gives us access to the static density-response function χ(q) and static local field correction G(q), which are compared to standard dielectric theories like the widespread random phase approximation. In addition, we study the high-frequency limit of G(q, ω) and provide extensive new results for the dynamic structure factor for different densities and temperatures. Finally, we discuss the implications of our findings for warm dense matter research and the interpretation of experiments.