diff --git a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
index 6b6b06333f6b2e93671d20172d95996ee68c878a..204e7af95db714a281dfd5af0ffa7b35d8dd9f28 100644
--- a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
+++ b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php
@@ -119,6 +119,9 @@ public function requestDestination(Request $request) {
    * Try to acquire a named lock and report the outcome.
    */
   public function lockAcquire() {
+    // Don't cache lock-testing pages.
+    \Drupal::service('page_cache_kill_switch')->trigger();
+
     if ($this->lock->acquire('system_test_lock_acquire')) {
       $this->lock->release('system_test_lock_acquire');
       return ['#markup' => 'TRUE: Lock successfully acquired in \Drupal\system_test\Controller\SystemTestController::lockAcquire()'];
@@ -132,6 +135,9 @@ public function lockAcquire() {
    * Try to acquire a specific lock, and then exit.
    */
   public function lockExit() {
+    // Don't cache lock-testing pages.
+    \Drupal::service('page_cache_kill_switch')->trigger();
+
     if ($this->lock->acquire('system_test_lock_exit', 900)) {
       echo 'TRUE: Lock successfully acquired in \Drupal\system_test\Controller\SystemTestController::lockExit()';
       // The shut-down function should release the lock.
@@ -152,6 +158,9 @@ public function lockExit() {
    *   The text to display.
    */
   public function lockPersist($lock_name) {
+    // Don't cache lock-testing pages.
+    \Drupal::service('page_cache_kill_switch')->trigger();
+
     if ($this->persistentLock->acquire($lock_name)) {
       return ['#markup' => 'TRUE: Lock successfully acquired in SystemTestController::lockPersist()'];
     }