Clear Cache on “master” Branch Commit
-
Hello,
I work in Bitbucket for all my code needs and am wondering if this is possible. I would like to flush the cache after a pull request is merged in to “master” or a commit is sent to “master”. I came up with a simple little hack that should work, but I would like to check here first before trying it.
1. Create a page named Clear Cache.
2. Change the permalink to something long and annoying like this.
clear-cache-fkrkvhvkfddkksd58887722200023658deressffkckvo
3. Use this custom page template and assign it to the page created in step 1.
https://bitbucket.org/snippets/the-news-triangle/AjXeA
4. In Bitbucket Pipelines after deploy to FTP, add another line of code to call a shell script. Inside the shell script, tell it to open the page created.
https://domain.com/clear-cache-fkrkvhvkfddkksd58887722200023658deressffkckvoBecause the page template is attached, the cache should be cleared. Then I can use .htaccess to restrict the file to hosts/IPs for Bitbucket.
Would this work? Seems good on paper, but not sure what would happen when trying it. Alternatively, I could use a shell script to SSH to server and execute a WP_CLI command to clear the cache.
Thoughts?
Thanks.
- The topic ‘Clear Cache on “master” Branch Commit’ is closed to new replies.