We performed ab initio calculations of the optical absorption spectrum and the wave-vector-dependent dielectric and energy-loss functions of graphite in the framework of the random-phase approximation. In the absorption spectrum, the most prominent peaks were analyzed in terms of interband transitions from specific regions of the Brillouin zone. The inclusion of the crystal local-field effects (LFE) in the response had an important influence on the absorption spectrum for light polarization parallel to the c axis. The calculated electron energy-loss spectra, even without LFE, were in very good agreement with existing momentum-dependent energy-loss experiments concerning the peak positions of the two valence-electron plasmons. Important aspe...