The mold may be more of a challenge than the dirt if the mold goes into the foam. That is really hard to deal with. There are different opinions on what you can get away with in cleaning the materials. The foam can be replaced
I lightly scrub mine with fabric cleaner and a soft bristle brush every now and then clean and treat with a fabric protectorant. I just wipe them down with a damp towel, rinsed in clean water to remove soap residue. I do not remove the covers from the foam.
The issues with more thorough cleaning methods is twofold: The covers may shrink or worse, they may fall apart (seams and zippers.)
If you think that the old covers are just about beyond useful life or look really bad, you can try to either hand wash or machine wash on delicate with cool water and detergent. It's taking a risk but may get you a few more years of life. Do not use a close drier.
You may find out that you can't get the original zippers to open. You can work on them but they just may not open.
The foam inside is wrapped in plastic. That serves two purposes: It stop major spills from soaking into the foam and it allows the foam to slip more easily into the cloth covers. If you remove it, you may not be able to get the foam back in correctly.
I have not heard from anybody who had their covers dry cleaned. Unfortunately, there are no care tags on my cushions so unless it said it's OK to dry clean, I wouldn't do it.