Collect the Caps... is the sixth mission of Dire, Dire Docks in Super Mario 64 and Super Mario 64 DS, though it is renamed Inside the Cage in the DS remake. In the original game, this mission is the course's final one and requires at least the Vanish Cap to be unlocked, while the DS version requires Luigi and his Power Flower ability.
Mario wearing the Vanish Cap and Metal Cap near the Star
In the original game, Mario needs to make his way to the boardwalk in the second area. On the boardwalk are the blue and green blocks. After Mario puts both the Vanish Cap and Metal Cap on, he needs to long-jump into the water to close the distance between them and the cage and then walk over to the cage on the right. The player needs to move quickly, however, as the ability is temporary. Despite the mission title, the player can also obtain the Power Star with the Vanish Cap alone by long-jumping off the boardwalk and swimming inside the cage, although this can be tricky due to Mario's slow swimming speed.
In the DS game, Luigi needs to make his way to the boardwalk in the second area. He then needs to collect his Power Flower from the red block to turn invisible and swim down to the cage under the large hole to the south. Inside the cage is the Star, but Luigi needs to swim inside quickly before the Power Flower's ability wears off.