Cut green beams in half if you like the pieces to be a little smaller. Blanch green beans; drop them into lightly salted boiling water and allow to cook to 3-4 minutes. Remove them from boiling water with a slotted spoon and immediately plunge into a bowl of ice cold water stop the cooking process. Drain the beans once they're cool and set aside.
Add the bacon pieces to a skillet over medium heat. Cook the bacon for 2 minutes, and then add onion and continue cooking until the bacon is done (but not crisp) and the onions are golden brown. Remove from heat and set aside.
In a separate saucepan, melt butter over medium heat. Sprinkle the flour into the pan and whisk immediately to evenly mix it into the butter. Cook for a minute or 2, and then our in the milk and half and half. Continue whisking constantly, while the sauce thickens, about 2 minutes. Add 1-1/2 teaspoons salt, some black pepper and the cayenne and then add the grated cheese. Stir while the cheese melts. Turn off heat.
Add the bacon/onion mixture and stir to combine, Add the green beans and stir gently to combine. Pour into a baking dish and top with the panko. Bake until the sauce is bubbly and the panko is golden, about 30 minutes.