I’m planning on using Magento’s inbuilt Custom Variable system to allow users to alter aspects of the styling. It is easy enough to bring this in to the header and have the styling options used with statements like:
Mage::getModel('core/variable')->loadByCode('backgroundColour')->getData('store_plain_value');
in a custom block, and including a this in the head block:
<block type="page/template_links" name="customvars" as="customVars" template="page/html/customvars.phtml"/>
However, I am concerned about performance. Are the Custom Variables Cached? If I were to have, say, 40 such variables, would this be a drain on resources at all?
I know I could include them all in one as a css block, but I want to keep the additional ease-of-use gains from separating them out.
The values from the “Custom Variables” feature in
are not, as far as I can see, cached specially. If it helps you solve your client’s problem I wouldn’t let this stop you from using them. Other things will cause performance problems sooner.
If you look at the primary place Magento uses these variables
You can see they’re loaded with the following chained method call
So you know there’s no caching at this level of code. If you jump to the
core/variablemodel class fileyou can see theres no caching logic in the
loadByCodemethod. A quick grep through the entire file also reveals no mention of the string “cache”.Then, if you look at the model resource
again there’s no special caching logic. Also, a grep through this file for the string “cache” reveals nothing.
Finally, running the following code in an otherwise empty controller action will dump the variable values.
If you do this, then use a separate tool to update the
core_variable_valuetable and reload the page, you’ll see the values are updated.All of this points to the values not being cached.