Are you working with a large site locally with Laravel Valet and it’s crawling? There’s a decent chance you’re running into performance issues with your local database.
WordPress Object Caching is a very quick way to speed up a site, local or production, by caching common queries in memory rather than fetching them from the database. We’ve covered this topic briefly before, which you can see here.
If you’re using Laravel Valet for local development, it’s actually really simple to get Redis working.
brew install redis
START REDIS ON SYSTEM STARTUP
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
START REDIS (LIKE RIGHT NOW)
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
INSTALL PHP REDIS EXTENSION
The version you choose here will depend on which version of PHP you are running locally. You can see this by running php -v in terminal.
PHP 7.0.19 (cli) (built: Jun 9 2017 16:20:40) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
In my example, I’m using PHP 7.0, so I’d install the PHP Redis extension like so:
brew install php70-redis
Just replace 70 with whatever version you are using. Examples: 56, 71
INSTALL WORDPRESS REDIS PLUGIN
There are a few good ones to choose from, but we prefer Redis Object Cache. Install it, activate it, and then go to Settings -> Redis and click “Enable Object Cache”.
You can also Network Activate the plugin. The only difference is that the Settings link is on the Plugins page itself.
Once you’ve followed these steps, you should see a huge improvement in speed. Which will give you more time to crank out some sweet, sweet Code Poetry.