A robust and efficient frequency dependent and non-local exchange-correlation fxc (r, r ′ ; ω) is derived by imposing time-dependent density-functional theory (TDDFT) to reproduce the manybody diagrammatic expansion of the Bethe-Salpeter polarization function. As an illustration, we compute the optical spectra of LiF, SiO2 and diamond and the finite momentum transfer energy-loss spectrum of LiF. The TDDFT results reproduce extremely well the excitonic effects embodied in the Bethe-Salpeter approach, both for strongly bound and resonant excitons. We provide a working expression for fxc that is fast to evaluate and easy to implement.PACS numbers: 71.15.Qe ; Since the 30's, excitons have been ubiquitous in our understanding of the optics of bulk materials, surfaces, nanostructures and organic/bio-molecules [1]. Only recently, however, has the first principle description of excitons in the optical absorption of extended systems been achieved, by solving the Bethe-Salpeter equation (BSE) of Many-Body Perturbation Theory (MBPT) [2]. The solution of the BSE is usually cast into an equivalent Hamiltonian problem whose dimension increases with the number of k-points and number of valence and conduction bands. However, even if the BSE results reproduce well the experimental spectra for semiconductors and insulators, the complexity of the calculations impedes the application of this technique to large systems such as nanostructures and complex surfaces.An alternative approach to the study of correlation in many-body systems is given by density-functional theory, in its static (DFT) [3] and time dependent formulations (TDDFT) [4]. Similar to the paradigm of DFT for ground-state properties, TDDFT has emerged as a very powerful tool for the description of excited states. In principle TDDFT is exact for neutral excited-state properties, and its simplicity relies on the fact that two-point response functions are needed instead of the four-point function of the BSE [1]. TDDFT casts all many-body effects into the dynamical exchange-correlation kernel f xc (r, t, r ′ ; t ′ ) = δv xc (r, t) /δρ (r ′ , t ′ ), where v xc (r, t) is the corresponding time-dependent exchange-correlation potential. It was early recognized [5] that, in extended systems, the standard approximations for v xc -local density (LDA) or generalized gradient (GGA) -that work extremely well for ground state properties, fail to describe, among other effects, the band-gap of insulators and semiconductors and the excitonic effects in the optical and energy-loss spectra [1]. Recently, promising results have been obtained within a polarization dependent functional derived in the framework of current-DFT [6] and within the exact-exchange DFT approach [7]. The calculated optical spectrum of silicon exhibits excitonic effects in qualitative agreement with experiment. However, empirical cutoffs were introduced to construct f xc [8], that somehow account for the screening of the electron-hole interaction. Furthermore, to-date the calculations of the absorption spectra of s...