In DDEV-Local v1.5.0 we introduced a feature called “webcache” which substitutes a fast filesystem in the web container for the slower Docker mount that we’ve been using. Docker on macOS and Windows really struggles with direct filesystem mounts, and so this is a workaround.
Here’s how it works: We introduce a Docker volume mount (which is a regular Linux filesystem, native to Docker) and then add an extra container (named “bgsync”) which runs the classic Unison tool to do a two-way sync between the fast filesystem and the slower, mounted filesystem. As far as the web container and webserver know, they’re operating on a blazingly fast Linux filesystem. But the bgsync container and Unison are out there keeping things that change on either filesystem synced.
The results are pretty amazing. I’m hoping you’ll watch the screencast below anyway, but here’s the spoiler: A Drupal 8 install is 7:00 minutes on DDEV-Local without webcache turned on, and 0:48 seconds with it enabled.
Things to know about webcache:
- Enable it with
webcache_enabled: truein your .ddev/config.yaml
- This is an experimental feature, we want to learn how it works for you. Two-way synchronization is not a fully solved problem anywhere. Please contact us via any of our support channels with your experiences.
- It’s only currently available for macOS. We expect to get it working for Windows soon (it helps even more there!). As far as we can tell, Linux doesn’t need it because the Docker filesystem mounting is direct, with no slow adaptation layer.
- Follow the logs in the bgsync container with
ddev logs -s bgsync -f
- Start syncing fresh with
ddev rm && ddev start(this doesn’t lose your database or anything else)
- Disable it at any time by setting
ddev start. The only problem is getting used to that fast experience and then going back to “normal” which used to be “ok”.
- The bgsync container is set up to not sync any directory named .git. This is to protect the .git on your host mount in case anything does go wrong. But it means that any git actions you do need to be undertaken on the host.