18

I'm trying to figure out what the purpose of the file /var/resource_config.json is in Magento. It appears to perhaps be a caching of a configuration, but can't see where in the source code it is being created and/or updated.

I'm in the process of setting up local/dev/staging/prod environments for an EE1.12 build and want to figure out if I can safely exclude it from my repo or whether I need to script some updates to it for deploys.

Maybe the flash image uploader in admin creates it?

Any ideas or directions to look?

1 Answer 1

31

This is a configuration cache file for the "alternative media store" system. This is a system where requests for media files are routed through get.php, and allows you to store media in the database instead of the file system. (That may be a gross over simplification, as I've never used the feature myself)

You can safely, (and should) exclude this file from deployments/source control, as it's a cache file and will be auto generated as needed. See the following codeblock in the root level get.php for more information.

if (!$mediaDirectory) {
    $config = Mage_Core_Model_File_Storage::getScriptConfig();
    $mediaDirectory = str_replace($bp . $ds, '', $config['media_directory']);
    $allowedResources = array_merge($allowedResources, $config['allowed_resources']);

    $relativeFilename = str_replace($mediaDirectory . '/', '', $pathInfo);

    $fp = fopen($configCacheFile, 'w');
    if (flock($fp, LOCK_EX | LOCK_NB)) {
        ftruncate($fp, 0);
        fwrite($fp, json_encode($config));
    }
    flock($fp, LOCK_UN);
    fclose($fp);

    checkResource($relativeFilename, $allowedResources);
}

Speaking in general terms, Magento's var folder serves the same purpose as the *nix var folder

Variable files—files whose content is expected to continually change during normal operation of the system—such as logs, spool files, and temporary e-mail files. Sometimes a separate partition

and should be isolated to particular systems (i.e. not a part of deployments)

4
  • 1
    Yes continuing on the same note it generally makes sense to exclude the entire /var folder from any deploy. May 9, 2012 at 21:41
  • 1
    Are the xml files in /var/package cache files as well?
    – Roscius
    May 10, 2012 at 15:31
  • 1
    I would think including the .htaccess file in /var in version control would be prudent for security reasons
    – Roscius
    May 10, 2012 at 15:43
  • 1
    @Roscius Sort of. They're files used by Magento Connect for package information. Whether they go with a deployment depends entirely on your deployment strategy. May 10, 2012 at 16:03

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.