Preheat the oven to 400 degrees F (200 degrees C). Butter an 8 cup (2 l) gratin dish.
In a skillet over medium-high heat, warm 1 tablespoon butter. Add the spinach and cook, stirring occasionally, until just wilted, 3 to 4 minutes. Press out any excess water. Transfer to a large bowl.
In a large saucepan over medium heat, melt the remaining 2 tablespoons butter. Add the onions and cook, stirring, until translucent but not brown, about 5 minutes. Add the garlic and then the flour and cook, stirring constantly, until nutty and just golden, about 1 minute. Slowly whisk in the cream and milk and continue cooking until thickened, about 3 minutes. Remove from the heat and stir in half of the cheese until melted. Fold the sauce into the spinach and season with salt and pepper. Transfer to the prepared gratin dish and top with the remaining cheese. Bake until the gratin is golden brown on top, about 10 minutes.