One of the best ways to prolong the life of your chain, cassette, chainrings, and derailleurs is to lubricate them before every ride.
I keep an old cotton rag and a bottle of lube by my front door and take a few short minutes as I’m heading out for a ride to quickly lubricate the above items.
Then I wipe off any excess drips or run with the same old rag.
A bottle of general purpose bike lube will cost you less than $10 and will last you a LONG time.
Replacing prematurely worn chains, cassettes, chainrings, and derailleur pulleys will cost you MUCH more than that. (In this case, an ounce of prevention truly IS worth a pound of cure.)
You will also find that your bike shifts smoother and more quietly when properly lubed.
Occasionally you will want to degrease your chain and any other components that have a built up of oil / dirt / grime on them, in order to prolong their life and increase their efficiency.
Here are some short youtube videos on how and where to properly lube your bicycle components.
https://www.youtube.com/results?search_query=how+to+lubricate+road+bike