It happened to me that when I tried to log in to the Magento admin, the login process took about 20 seconds or more. It was really annoying, and I was sure that it is a coding issue, because the rest of the site worked almost instantly (even in the admin page after logging in). After some investigation I’ve found out what causes this problem: Magento’s cache. Incredible, is it?
The explanation is really simple. When your site grows, the number of cache files will be great. Even if cache is split into mage–0, mage–1, etc, inside those folders could be present thousands of files. And sometimes Magento clears the cache partially, which is really slow because of the large number of files. But what kind of cache needs to be cleared while logging into the backend? Well, the cached links from the menu. Yes, I didn’t believe it first time. Do you remember those “/key/abcd34242347987def3948” in the URLs of the pages of the admin site? That is called “Secret Key”, which is cached every time you log in, and of course, before the caching it happens the clearing of the previous caches. In this situation Magento will have to loop over those thousands of files in the cache folders and parse them. That took me twenty seconds.
The solution? Turn off the “Secret Key” feature. How?
System -> Configuration -> Admin -> Security -> Add Secret Keys to URLs -> set it to No, then Save Config
It will take some time to save the configuration, but after then the login process will be almost instant.
An alternative solution is to clear the cache more often. The number of files in the cache folders will be low for a while, so the login process will be quick. But obviously, this is just a temporary solution.