Pergunta

I was faced with a caching error this afternoon which is generally (by the unanimous opinion of the interwebs) solved (and in this case was) by deleting app/etc/use_cache.ser. What exactly does this file do? The content is not descriptive by any means. Also, at what point does Magento regenerate this file on its own?

Foi útil?

Solução

It was a serialized PHP array that was a flag for enabling caching capability in the application. This includes block, layout, translation, config, eav and more. This was discontinued some time after 1.2 or so in 1.4 alpha 3 - and as such I think that you have an out of date Magento install.

The method that finds the file on disk to write/read is in the class Mage_Core_Model_App and is marked as deprecated:

/**
 * Get file name with cache configuration settings
 *
 * @deprecated after 1.4.0.0-alpha3, functionality implemented in Mage_Core_Model_Cache
 * @return string
 */
public function getUseCacheFilename()
{
    return $this->_config->getOptions()->getEtcDir().DS.'use_cache.ser';
}

It typically looked something like this:

a:7:{s:6:"config";i:0;s:6:"layout";i:0;s:10:"block_html";i:0;s:9:"translate";i:0;s:11:"collections";i:0;s:3:"eav";i:0;s:10:"config_api";i:0;}

Which, when unserialized can be visualized as a PHP array like such:

Array
(
    [config] => 0
    [layout] => 0
    [block_html] => 0
    [translate] => 0
    [collections] => 0
    [eav] => 0
    [config_api] => 0
)

The problem with a file of this type is it has to be writable by the server, and having it live in app/etc/ could expose potential issues to your local.xml file making your database configuration and encryption keys readable if you have misconfigured permissions.

This was replaced at some point with an admin cache management screen that gave you the ability to enable or disable certain caching areas.

Some more information about troubleshooting issues with use_cache.ser:

http://www.magentocommerce.com/wiki/groups/227/cache_is_not_writable

Serializing in PHP: http://php.net/manual/en/function.serialize.php

Outras dicas

For versions 1.4+ this file shouldn't exists. It became deprecated in version 1.4.0.0-alpha3.
For versions before 1.4 this file was used to store the state of the cache types (enabled/disabled). It stored what you see under the menu System->Cache Management.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top