Magento – Magento Cache in two places, tmp and var/cache

cachemagento-1.9

I was changing my secure Base Skin URL, Base Media URL,Base JavaScript URL to a cdn url yesterday and had a typo, which messed everything up on Secure pages, including the Admin.

So I went in to DB and changed the core_config_data entries to correct it. Cleared my var/cache in my magento directory. And it kept showing the incorrect url for css,js and images.

When I looked in Admin -> Configuration -> Web the entries were all changed, so it was a caching issue.

I couldn't figure out where it was caching, because I would clear var/cache and then Magento would recreate the cache files in var/cache.

So eventually, I figured out that it was caching on the server at /tmp/magento/var/cache
But the weird thing is, that it seems to cache in var/cache and /tmp/magento/var/cache
It also seems to be doing this for sessions!
And some logs go to /tmp/magento and some to var/log

I have var/cache in my magento directory set to 777

Any ideas why it is splitting the cache? why is going to tmp if I have var/cache set to 777?

Best Answer

If you don't have proper permissions on the var/ folders, Magento can write its cache information to the system /tmp folder.

This can lead to a situation where you've changed the base URLs in the Magento database, cleared cache (manual deletion of all mage-?? folders in var/cache), (cleared APC cache if you're running the op-code cache), (manually disabled the compiler (1.4.x.x and later)) and the system still looks for the original site.

Most people who own their own server discover that the site magically starts working after fixing, clearing and resetting permissions and then rebooting the server. The server reboot clears /tmp of the Magento cache files and Magento finally starts looking at its own configuration to find where it's located.

If you have this happen, set your var/ folder permissions so that both the login user and web server process can access the var/ folder tree. Then if you have permissions to navigate over to the /tmp folder, go delete the /tmp/magento folder. Pay particular attention to permissions on the subfolders var/cache/ and var/tmp/ must be writable by the web server process which may be running as www-data, nobody, etc.

Screen shots of this in action...

The Magento directory found in /tmp...

The Magento directory found in /tmp

And the Cache living in that directory. Note the path -> /tmp/magento/var/cache

Magento Cache subdirectories...

Related Topic