Heat the oven to 350 °F. Have the baking dish ready so the coated broccoli can go straight into the oven.
Bring a large pot of water to a boil and set a large bowl of ice water nearby, then blanch the broccoli for 1 1/2 minutes. Drain it and immediately chill it in the ice water until the florets are bright green and crisp-tender.
Drain the chilled broccoli well and place it in a dry bowl. Press away lingering water with clean towels so the bowl does not collect moisture.
Coat a small skillet with oil spray, then cook the onions for 6 minutes before stirring in the garlic for 1 minute. The onions should soften and the garlic should smell fragrant without browning.
While the onions cook, process the softened cream cheese, ranch dressing, and cayenne pepper until smooth. The sauce should look creamy and uniform, with no visible cream cheese pieces.
Add the cooked onions and garlic to the broccoli, then fold in the cream cheese sauce until everything is coated. Work while the vegetables are still warm enough to release a little steam but not dripping wet.
Spread the mixture in an 8 x 8 baking dish and cover the surface with the cheddar and parmesan. Keep the cheese in an even layer for consistent browning.
Bake for 25 minutes. The casserole is ready when the perimeter bubbles and the topping is melted with light golden spots.