Automatically clear the render cache when templates change
May 11, 2017
Recently someone asked whether we can disable CSS/JS aggregation and render cache on local development sites. It is totally easy to do that, but we realized that keeping render cache enabled is important to not miss caching issues during development and then have issues once the site is deployed.
On the other hand its quite annoying to have to clear the render cache manually, everytime you touch any template.
As solution we have written a script which invalidates the render cache when someone touches a template.
Show me the code!!
We used a tool which listens to changes in the file system.
Everytime a file changes we call a script, which then clears the render cache.
Required steps to set it up:
Add a php helper script:
Actually listen to filesystem events:
For some extra goodness place this in a composer script.
Have you done anything similar and maybe solved it different?