01463: HTML cached pages are missing HTMLStylesFmt
Description:
If I enable HTML caching with $EnableHTMLCache then page contents get cached as I would like. However if a recipe sets a value using $HTMLStylesFmt
within a markup handler then this is not cached and is missing from the page when the cache is hit.
The simplest fix is for the recipe to set $NoHTMLCache=1 to disable caching, but then of course I don't have caching. Alternatively it can inject its styles outside of a markup function, but that will fail with any dynamic style generation. I presume it will also affect the similar $HTMLHeaderFmt
and $HTMLFooterFmt
collections.
This particularly affects me with SourceBlock, which injects CSS based on the source code languages it sees.
To fix it, I guess there would need to be a way to capture these "layout variables" alongside the HTML in the cache. Maxim? February 09, 2021, at 11:08 PM
You can manually set the $HTMLHeaderFmt
and $HTMLStylesFmt
format in config.php. --Petko February 10, 2021, at 02:00 PM
Yes - but that means injecting styles into 100% of pages for all possible cases (I notice some recipes do this, e.g. HandyTableOfContents called it out as a fix in version 2017-09-07). For SourceBlock, it is getting the CSS on a per-language basis from GeSHi and thus I'd have to front-load all styles into every page for all languages I expect to use. I suspect the answer is that either SourceBlock should disable HTML caching or it should inject the CSS into the page, not the header... Maxim? February 11, 2021, at 06:51 PM