diff --git a/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php b/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php
index c88469c..a486644 100644
--- a/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php
+++ b/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php
@@ -25,7 +25,10 @@ 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)) {
       $value = $this->requestStack->getCurrentRequest()->query->get($query_arg);
@@ -35,13 +38,9 @@ public function getContext($query_arg = NULL) {
       elseif ($value !== '') {
         return $value;
       }
-      else {
-        return '?valueless?';
-      }
-    }
-    else {
-      return NULL;
+      return '?valueless?';
     }
+    return '';
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Cache/Context/QueryArgsCacheContextTest.php b/core/tests/Drupal/Tests/Core/Cache/Context/QueryArgsCacheContextTest.php
index e3fc0dd..5c30a92 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', ''],
       [['llama' => ['rocks', 'kitty']], 'llama', '0=rocks&1=kitty'],
       [['llama' => ['rocks' => 'fuzzball', 'monkey' => 'patch']], 'llama', 'rocks=fuzzball&monkey=patch'],
       [['llama' => ['rocks' => ['nested', 'bonobo']]], 'llama', 'rocks%5B0%5D=nested&rocks%5B1%5D=bonobo'],
