I'm stuck with the photon propagator, at chapter 5 of Mandl and Shaw QFT book. They say that since the Maxwell Lagrangian density for the free Electromagnetic field has a conjugate momenta to the field $$\frac{\partial L}{\partial(\partial_0 A^0)}=0$$ Then one cannot choose a canonical quantization.
Now in chapter 5 they say that choosing the Fermi Lagrangian density $$ L_{fermi}=-\frac{1}{2} \partial_\nu A_\mu \partial^\nu A^\mu - J_\mu A^\mu \tag{5.10}$$ with sign convention $(+,-,-,-)$ for the electromagnetic field the momenta is well defined $$\frac{\partial L}{\partial(\partial_0 A^\mu)}={-\dot{A}^\mu}\tag{5.11}$$ and one can quantize in a canonical way, because now it makes sense to introduce commutation relations: $$[A(x^\mu),\dot{A}^\mu (y^\mu)]=i\hbar\delta^3(x^\mu-y^\mu).\tag{5.23}$$
Now We also know that the Fermi lagrangian density is not gauge invariant, since there is the interaction term ( $A^\mu$) $$A^\mu \rightarrow A^\mu+\partial^\mu f \tag{5.7}$$ that transforms under gauge tranformation for $A^\mu$. Is it right to say that the NON Gauge invariance of the Fermi lagrangian is not a problem because the action changes but gives the same equations of motion? (this must be because of a total divergence in the action in which the Non gauge interaction term is included); I have heard this argument from my professor but i think i missed the sense. Can someone help me with this?