Description
Consider, as a real case scenario, an application that integrates with Apache FOP in a way that, by overriding Page's getMarkupType(), makes it possible to have a component render its .fo markup (to generate a PDF) instead of the usual html, depending on whether it is added to a Page with the fo MarkupType or the standard html one.
This means the typical Panel of such application has two markup files, an html one and a fo one: Panel.html and Panel.fo.
The default CachingResourceStreamLocator makes use of ResourceReference#Key for the cache. That Key completely ignores the extension of the file or, better, assumes it is part of the name, while for markup files this is apparently not the case. Basically, Panel.html and Panel.fo have the same Key, the name of which is simply "Panel".
Therefore, when a Panel is first rendered in html, its html markup reference is cached and there is no way to make it render again in fo, because the cache will always return the html markup reference.
A workaround suggested by Martin Grigorov in the Users mailing list is to override #getVariation() for the pages and return "html" and "fo" respectively.
However, the solution would be to fix CachingResourceStreamLocator to fully support this use case and properly cache different markup files of the same class.