The dynamical exchange-correlation kernel $f_{xc}$ of a non-uniform electron gas is an essential input for the time-dependent density functional theory of electronic systems. The long-wavelength behavior of this kernel is known to be of the form $f_{xc}= \alpha/q^2$ where $q$ is the wave vector and $\alpha$ is a frequency-dependent coefficient. We show that in the limit of weak non-uniformity the coefficient $\alpha$ has a simple and exact expression in terms of the ground-state density and the frequency-dependent kernel of a {\it uniform} electron gas at the average density. We present an approximate evaluation of this expression for Si and discuss its implications for the theory of excitonic effects.