In this work we study the influence of fluid viscoelasticity on the performance of lubricated contacts in the presence of cavitation. Several studies of viscoelastic lubricants have been carried out, but none of them have considered the possibility of the presence of cavitation. To describe the effect of viscoelasticity, we use the Oldroyd-B model. By assuming that the product between ϵ, i.e. the ratio between vertical and horizontal length scales, and the Weissenberg number (Wi), i.e. the ratio between polymer relaxation time and flow time scale, is small, we can linearise the viscoelastic thin film equations, following the approach pioneered by "Tichy, J., 1996, Non-Newtonian lubrication with the convected Maxwell model." Consequently, the zeroth-order in ϵWi corresponds to a Reynolds equation modified to describe also the film cavitation through the mass-conserving Elrod-Adams model. We consider the flow of viscoelastic lubricants using: (i) a cosine profile representing a journal bearing unwrapped geometry, and (ii) a pocketed profile to model a textured surface in lubricated contacts. The introduction of viscoelasticity decreases the length of cavitated region in the cosine profile due to the increasing pressure distribution within the film. Consequently, the load carrying capacity increases with Wi by up to 50% in the most favorable condition, confirming the beneficial influence of the polymers in bearings. On the other hand for the pocketed profile, results show that the load can increase or decrease at higher Wi depending on the texture position in the contact. The squeeze flow problem between two plates is also modeled for viscoelastic lubricants considering an oscillating top surface. For this configuration a load reduction is observed with increasing Wi due to the additional time needed to reform the film at high Wi. Furthermore, if viscoelastic effects increase, the cavitation region widens until reaching a value of Wi for which a full-film reformation does not occur after the initial film rupture.