Keep your trash cans free of flies.
“As the result of experiments it has been found that a small amount of ordinary Borax sprinkled daily in the dustbin, which is one of their favorite haunts, will put a stop to the breeding of [flies].”