2

Last night I was in the process of launching an upgraded Magento site but ran into caching problems which ultimately caused me to postpone the launch.

My setup:

  • New site (1.9): new.domain.com -> no cache
  • Old site (1.7): domain.com -> memcache/redis/fpc

Both sites are on the same server in folders corresponding to their domain name

My process:

  1. Rename folder domain.com to domain.com.backup
  2. Rename folder new.domain.com to domain.com
  3. Create maintenance.flag
  4. Update .htaccess file to use domain.com instead of new.domain.com
  5. Rename /app/etc/local.xml to /app/etc/local.xml.backup
  6. Rename /var/cache to /var/cache.backup
  7. Rename /var/session to /var/session.backup
  8. Flush Magento cache, memcache and redis

At this point, I'm hoping to refresh the page and get the Magento installation page so I can upgrade the live database (after backing up of course). However, I received an error message about failing to open a stream in a PHP file at new.domain.com.

So the base URL of new.domain.com must have been cached by the Magento configuration but there was no way for me to clear it. Anyways, after several hours of trial and error I finally came up with a pretty ridiculous solution.

All I need to do when moving the site between domains is simply update the app/Mage.php file (e.g. download and reupload). No actual change to the file source is needed.

Now to my main question. Why does updating the Mage.php file seemingly result in the clearing of the Magento configuration cache?

@John

Thanks for the comment. I did suspect that the cache was invalidating due to the timestamp change to that file. I cleared the var/cache folder by renaming it but this had no effect since I'm using memcache instead of the file system for the standard Magento cache management.

It would seem that just simply using the Flush Magento Cache and Flush Cache Storage buttons do not actually cause the memcached configuration to be refreshed (along with flushing it from the command line). Updating Mage.php is the only thing that seems to trigger the refresh.

2

You have mentioned three different caching technologies there. But without seeing your exact setup its difficult to say which is being used for what. I am going to work on the presumption that your configuration is using the file based cache which will ultimately be served by Zend_Cache_Backend_File. (http://framework.zend.com/apidoc/1.9/Zend_Cache/Zend_Cache_Backend/Zend_Cache_Backend_File.html#_fileGetContents)

When you download the file and re-upload it you state your not making any changes however it is likely this is not actually the case. When you downloaded the file to your local computer unless you instructed your FTP/SFTP client to preserve the date/time of the file it will be updated with a new created and modified time as of the time the file is created.

Consequently when you have re-uploaded the file, you have essentially uploaded a new file to replace the core of Magento. The caching mechanism should pick up on this being a new file and will invalidate the caching to ensure the most upto date files are being used.

I suspect if you went into var/cache and deleted all the files from there it will have the effect as what you have done since you have deleted the cache manually so it will be forced to regenerate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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