We present a consistent emph{ab initio} computation of the longitudinal response function $R_L$ in $^{40}$Ca using the coupled-cluster and Lorentz integral transform methods starting from chiral nucleon-nucleon and three-nucleon interactions. We validate our approach by comparing our results for $R_L$ in $^4$He and the Coulomb sum rule in $^{40}$Ca against experimental data and other calculations. For $R_L$ in $^{40}$Ca we obtain a very good agreement with experiment in the quasi-elastic peak up to intermediate momentum transfers, and we find that final state interactions are essential for an accurate description of the data. This work presents a milestone towards emph{ab initio} computations of neutrino-nucleus cross sections relevant for experimental long-baseline neutrino programs.