I read Fabien saying (in a pull request that got rejected) that this should be handled by the web server. So I changed my maintenance script to modify the server config instead of the framework.
The problem was the server was not able to remove the cache headers. But then I found the NginxHttpHeadersMoreModule which worked just fine, so problem solved.