I think the secret is to wash out immediately after use.....but, who does that?
However, unscrewing g the spray head and brushing the tube end that sucks up the liquid and soaking in hot soapy water usually works for me. I have a decent sprayer that I rarely use but I buy cheapo sprayers for a pound or so and try to keep them going forever.