Proper sanitation and food storage practices are key ways to help prevent problems with flies and gnats. Outside of your home, you should make sure that any outdoor garbage cans have tight fitting lids and that they are stored a distance away from the exterior of your home. If compost piles are on your property, place them a distance away from your home and keep covered, and vegetable gardens should be maintained so that any fallen vegetables are picked up and discarded. If you own pets, make sure to pick up their waste daily and dispose of it properly.
Inside your home it is helpful to reduce areas of moisture by fixing any leaky pipes or fixtures, routinely wiping down sinks, and cleaning out sink and tub drains. Food in kitchen and pantry areas should be stored in sealed containers or in the refrigerator; leaving food out on tables and counters is like inviting flies to an all they can eat buffet. It is also a good idea to quickly pick up spills and crumbs and to regularly collect and remove garbage from your home.