My party attacked the Earth Temple first, they used spider climb to sneak around into the prophet's lair, fought him and his shadow demon, the prophet fled before they could finish him. They tried taking a short rest there but all hell broke loose as he mustered and organized attack against them and they barely escaped. They were forced to retreat to safety and rest up.
On the way back they encountered patrols who then alerted the temple. The party fought it's way in against an alert and beefed up defensive force at the doors, the shadow monk shadow stepped into the midst of the enemy and then was polymorphed by the wizard into a T-Rex. Epic fight, they barely survived (actually the wizard took a hit, broke concentration and the monk took a huge beating before she could be re-t-rexified.
They found the water temple second and had an easier time of that because the warlock could cast water breathing. They never took a long rest until after they had pretty much cleared it of all monsters that might organize a counter attack (and after they rested, they picked a fight with the dragon turtle).
Basically, sure, I "allow" long and short rests but the monsters behave rationally. Organized monsters/NPCs if they feel confident will send out scouting patrols for find and harass the PCs and will set up stronger defenses and even bring in reinforcements. Monsters that are not organized or if the organized ones have suffered great losses might flee to other strongholds.
I served in the infantry in Iraq. We had about 100 soldiers living in a small compound along with 30 or so Iraqi soldiers. At any given time we had one squad (11 soldiers) plus some leadership actively defending the compound. Two other squads were resting but ready to fight, a platoon patrolling or executing missions outside the compound and another one resting/performing maintenance. In the event of an attack, it would take about a minute or so for the two reserve squads to react to the threat and they don't just all go to the threat (because it is likely a feint). One moved to designated points, the other moved under the direction of the officer of the watch. It could take upwards of 10 minutes for the resting/maintenance platoon to fully gear up and organize. If the fight was still going, they would be able to move en masse against any sustained threats.
So this is how I run my dungeons...once alerted, the monsters don't automagically know where the PCs are and mass on them. Some move toward the PCs within about a minute, others move to other defensive positions. This takes usually about 10 rounds. If there is leadership, they gather the bulk of the strongest monsters and move against the PCs after about 10 minutes or so...give or take.