diff --git a/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php b/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php
index 0926ba6..bd742a2 100644
--- a/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php
+++ b/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php
@@ -25,20 +25,21 @@ public static function getLabel() {
    */
   public function getContext($query_arg = NULL) {
     if ($query_arg === NULL) {
-      return $this->requestStack->getCurrentRequest()->getQueryString();
+      // All arguments requested. Use normalized query string to minimize
+      // variations.
+      $value = $this->requestStack->getCurrentRequest()->getQueryString();
+      return ($value !== NULL) ? $value : '';
     }
-    elseif ($this->requestStack->getCurrentRequest()->query->has($query_arg)) {
+    if ($this->requestStack->getCurrentRequest()->query->has($query_arg)) {
+      // Requested argument exists in request.
       $value = $this->requestStack->getCurrentRequest()->query->get($query_arg);
       if ($value !== '') {
         return $value;
       }
-      else {
-        return '?valueless?';
-      }
-    }
-    else {
-      return NULL;
+      return '?valueless?';
     }
+    // No argument in request.
+    return '';
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Cache/Context/QueryArgsCacheContextTest.php b/core/tests/Drupal/Tests/Core/Cache/Context/QueryArgsCacheContextTest.php
index 93a11c5..3e13b23 100644
--- a/core/tests/Drupal/Tests/Core/Cache/Context/QueryArgsCacheContextTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/Context/QueryArgsCacheContextTest.php
@@ -31,15 +31,15 @@ public function testGetContext(array $query_args, $cache_context_parameter, $con
    */
   public function providerTestGetContext() {
     return [
-      [[], NULL, NULL],
-      [[], 'foo', NULL],
+      [[], NULL, ''],
+      [[], 'foo', ''],
       // Non-empty query arguments.
       [['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], NULL, 'alpaca=&llama=rocks&panda=drools&z=0'],
       [['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], 'llama', 'rocks'],
       [['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], 'alpaca', '?valueless?'],
       [['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], 'panda', 'drools'],
       [['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], 'z', '0'],
-      [['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], 'chicken', NULL],
+      [['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], 'chicken', ''],
     ];
   }
 
