Jaime had saved the King's Landing from burning by wildfire, but didn't save it from rape and pillage by Lannister soldiers, which is a thing that the city had never forgiven the Lannisters. We know that from two unlikely suspects: Tyrion and Cersei, who both spoke with pyromancers. In their chapters we are told that
1) There was a cache of wildfire (200 jars) found a few years (288 AC) after Robert's rebellion (282-283AC ) under The Sept of Baelor, causing the current First Septon to freak out and pyromancers to have to move the wilfire under the cloak of night. Keep in mind that Sept of Baelor is in the middle of the city, an emergency shelter that can temporarily house thousands and is more likely for women and children from the whole town to go there to pray to Maiden for mercy in the middle of battle.
2) Another cache was found in a locked cellar under Dragon Pit (300 jars), next year 299 after the cache found under the Sept. Dragon Pit is on the different hill, surrounded by slums, shops, warehouses, alehouses and whorehouses. All the cellars and storage in and around it is heavily used. So the chance that it was the older and forgotten cache before the rebellion is practically zero.
3) Three elder (top management) pyromancers (Rossart, Garigus and Belis, who all knew the plan) are known to have gone missing and been killed during the Sack of King's Landing and a couple days later. In his chapter, Jaime confirms he tracked and killed them. Keep in mind that pyromancers (and especially elder pyromancers) dress in very rich and distinctive clothes and are usually unarmed. They are more likely to be captured than killed during the battle, because they are literally worth their weight in gold because of their knowledge how to make wildfire.
4) Wildfire is expensive, each jar worth a dozen gold coins and extremely volatile. You don't just lose 500 jars of it. One jar is enough to burn a huge ship. 200 would be enough to burn a quarter or a fifth of a city.
More details here:
https://awoiaf.westeros.org/index.php/Wildfire_plot Apparently, there was a cache under every city gate as well. Which meant that once the fire started (almost a certainty during siege, because the invaders are likely to try to burn the gates. Thanks Pycelle, you are our savior for telling Aerys to let Tywin in!) there would have been no escape from the burning city.