Based on the info in the ticket I made a jsp page in alfresco webapp with this code
So I just have to call that jsp when I want to clear the cache. That way the default behavior of compile script is kept (performance) and I don't have to wait for 3.1SP1).