The modern theory of dispersion forces uses macroscopic dielectric functions epsilon(omega) as a central ingredient. We reexamined the formalism and found that at separation distance < 2 nm the full dielectric function epsilon(omega,k) is needed. The use of epsilon(omega,k) results in as much as 30% reduction of the calculated Hamaker constants reported in the current literature. At larger distances, the theory reduces to the traditional method, which uses dielectric functions in the long-wavelength limit. We illustrate the formalism using the example of interaction between two graphite slabs. This example is of importance for intercalation and exfoliation of graphite and for the use of exfoliated graphite in composite materials. The formalism can also be extended to study anisotropic van der Waals interactions.