Gabriel-
I've investigated the caching issue a bit- there's nil purging for the sections and the full page view, so the code would need to be changed to send no-cache headers, otherwise anon users will get old versions of the page.
?? When would anons get old versions of the page? I just edited a couple of sections on wikidev.net anonymously and all changes show instantly.
I've done some benchmarks of a long testpage (http://wikidev.net/Long_testpage, 267.8Kb raw, 57.8kb gzipped for normal browsers) with section folding/no caching vs. disabled section folding/caching enabled. The (not surprising) result: Section folding without caching is about 20 times slower.
Actually, section *expanding* without caching is slower. You have benchmarked with collapse=false. That will only happen if an expansion is explicitly requested, which is a dynamic operation which may well be slow. How about benchmarking with the auto-collapsing (no URL parameters) versus the old behavior (set threshold to 0)? Surely the massively smaller pages far outweigh any benefits of caching?
Re: the duplicate TOC, investigating.
Regards,
Erik