XenForo's Template Compiler & max_allowed_packet

Jake B.

Well-known member
So, we've recently encountered an issue with our compiled PAGE_CONTAINER template being > 1MB which seems to be what a lot of people are using for max_allowed_packet in their MySQL configuration. Short of removing functionality is there anything that can be done to reduce this? From what I can see it's compiling PAGE_CONTAINER along with any template that is included from page_container, and any templates those templates include and so on, which grows quite fast as more 'global' features are added.
 
1MB is the default max_allowed_packet value in MySQL. You really need to build with that in mind as a max, though TBH, I'm somewhat flabbergasted that a template could get that big. The compiled default PAGE_CONTAINER I have appears to be ~75KB, so we're talking more than order of magnitude bigger.

If you can't remove features or reduce the raw size of what you provide, you'll need to find a way to pull elements in that don't use include. Template includes are resolved at compile time for performance (though it creates a bigger template and doesn't allow recursion). You'd either need to use an add-on to "compose" a template from smaller templates in PHP or, similarly, use custom template helper functions to pull this data in.
 
We add modern features, so off-canvases, extended footer options, and a few other features. Its nothing more than a few modern features. I did a character count on view source, and got around 138kB for your index page. On ours, its about 146kB. So its not that big of a difference, at least in markup. But understandably there are more conditional statements and other things that might cause issue.
 
Top Bottom