The dynamic structure factor of materials is proportional to their linear electronic response and it displays their excitation spectra. Usually the response is measured on the same length scale as the perturbation. Here, we illustrate that much can be gained by studying also the mixed dynamic structure factor, which connects different spatial components of perturbation and response. We extend state-of-the-art ab initio calculations to access the mixed dynamic structure factor, including excitonic effects. Using bulk silicon and lithium fluoride as prototype examples, we show that these effects play a crucial role above and below the quasiparticle gap, and are needed in order to explain coherent inelastic x-ray scattering experiments. Our approach also yields important information concerning the microscopic structure of time-dependent density functional theory.