Just create the config.cache - we already have a good $config, no need to reload and parse the XML after writing it
Just create the config.cache - we already have a good $config, no need to reload and parse the XML after writing it