Steep density gradients generally lead to improved plasma performance in the neoclassically optimized stellarator W7-X. This is evident in the global energy confinement time as well as in the ion temperature and can be explained by a strong reduction of the ion temperature gradient turbulence. Such conditions can experimentally be realized by several methods: injection of cryogenic hydrogen pellets, appropriate combination of neutral beam and electron cyclotron resonance heating (ECRH) and, in some cases, with low power of ECRH after preconditioning of the first wall. The duration of the improved phases is determined by the ability to sustain the steep density gradient, by technical limitations of the involved systems and, eventually, by the plasma stability. This paper gives an overview of relevant experimental results and presents example discharges where the improved confinement conditions could be extended to multiple seconds: up to 4 s using neutral beam injection and from 14 to 40 s with steady state pellet injection. In these plasmas the turbulent thermal diffusivity is reduced by a factor of 3 to 4 in a broad radial range, which allows high ion temperatures of up to 3 keV at the densities of about m−3.