We study vortex lattice (VL) dynamics in patterned Nb films containing dense periodic arrays of sub 50 nm magnetic nanodots or holes, by means of ac susceptibility measurements. For both types of samples, we observe matching effects within a wide temperature range, determined by the periodicity of the strong artificial pinning potential. Below a crossover reduced temperature t* = 0.75, the ac vortex mobility and matching fields are different for increasing or decreasing fields. Low temperature field cooling experiments indicate that the hysteretic behavior is not related to different intensities of magnetic induction B in the ac penetrated region of the samples. The fact that hysteresis appears in both patterned samples when the intrinsic random pinning becomes stronger, together with the absence of hysteresis in a reference unpatterned Nb film, suggests that the interplay between random and periodic pinning, independent of its origin, induces VL metastability below t*, which leads to the observed irreversibility. [ABSTRACT FROM AUTHOR]