I've heard something about caffeine coating on the teeth will help in preventing cavities (caries).
Is this true or just a myth?
The answer to your specific question in particular, is rather indefinitive.
However, when a the bean/extract of the Coffea canephora plant is used in a strong brew of black coffee it was shown to significantly defend the teeth from bacteria upon exposure! Cavities, are caused by bacteria!
The conclusion of this study clearly shows that the very high polyphenol content, in the bean/extract from the coffee plant caused the bacterial cells to burst or lyse. Further more, there is evidence that it may aid strengthening of the teeth as, when the bacteria lyse calcium is released into the medium.
Additionally, a study in the same agenda proves that the high caffiene content in the Robusta bean, from the Coffea canephora plant, contributes to the ability of the bean to cause an antiadhesive effect in the saliva, preventing the bacteria from initially adhering to the host i.e. the tooth, and hence preventing the receptors on your tooth surface from communicating with the bacterial cells that cause decay/cavities (Streptococcus mutans). Bacterial cells have no vision, they arrive at their destination per say, by cell signalling so, interfering with the receptor sites on your teeth means that they have a loss of direction.
When the bacteria do successfully attach to the teeth they signal other bacterial cells causing colonization on the enamel surface. From there on they synthesize sucrose and henceforth, produce acid as a waste product causing; erosion; decay; cavities.