Git post checkout hook for purging Magento caches
05 of November, 2013
Probably anyone who ever worked with Magento knows that it heavily relies on caches. Which, obviously, is good for speeding things up, but as a developer sometimes I find it quite annoying to have to clear it all the time when switching between features in development. I store my projects in Git and each feature is isolated into separate branch, so most obvious way to automate it was to use post checkout hook.
Git hooks are very straightforward. They are small custom scripts, which fire off when certain events happen. By default there are few sample executable bash scripts, which live in .git/hooks directory.
I use Vagrant for firing up and managing project virtual machine and usually have Redis and Varnish setup for caching. First I flush these service caches in my vagrant box, then I remove file caches. Like this:
Right. Looks slow. But is it too slow? On my laptop it takes up to 8 seconds. I still have to realize how painfully show it is in reality, but so far was okay - just enough time to sip my tea or water from a glass.comments powered by Disqus