The optical conductivity of a metal near a quantum critical point (QCP) is expected to depend on frequency not only via the scattering time but also via the effective mass, which acquires a singular frequency dependence near a QCP. On the other hand, the quasiparticle residue Z, no matter how singular, does not appear in the conductivity as the latter probes quasiparticles rather than bare electrons. In local theories of QCPs, however, the ratio of band and renormalized masses, m*/m(b), coincides with 1/Z, and it is not straightforward to separate the two quantities. In this work, we use a direct diagrammatic approach and compute the optical conductivity, sigma'(Omega), near two-dimensional (2D) nematic and spin-density wave (SDW) QCPs, using the local approximation in which Z = m(b)/m*. If renormalization of current vertices is not taken into account, sigma'(Omega) is expressed via Z = m(b)/m* and the transport scattering rate gamma(tr) as sigma' (Omega) alpha Z(2)gamma(tr)/Omega(2). For a nematic QCP (gamma(tr) alpha Omega(4/3) and Z alpha Omega(1/3)), this formula suggests that sigma'(Omega) would tend to a constant at Omega -> 0. We explicitly demonstrate that the actual behavior of sigma'(Omega) is different due to strong renormalization of the current vertices, which cancels out a factor of Z(2). As a result, sigma' (Omega) diverges as 1/Omega(2/3), as earlier works conjectured. In the SDWcase, we consider two contributions to the conductivity: from hot spots and from " lukewarm" regions of the Fermi surface. The hot-spot contribution is not affected by vertex renormalization, but it is subleading to the lukewarm one. For the latter, we argue that a factor of Z(2) is again canceled by vertex corrections. As a result, sigma' (Omega) at a SDW QCP scales as 1/Omega down to the lowest frequencies, up to possible multiplicative logarithmic factors.