Feature summary
There should be a Extension:ParserFunctions variable for the content model of a page.
Suggest {{CONTENTMODEL}} and {{CONTENTMODELE}}.
A standard Wikitext page would return Wikitext. Other content types could not return the variable within the page itself, but this variable could be used in wikitext-based system messages; so a JavaScript page returns JavaScript, a CSS page returns CSS, etc. This info can be used to trigger switches.
This would not affect caching, given that content model changes are rare.