diff --git a/src/StackMiddleware/PageCacheIgnore.php b/src/StackMiddleware/PageCacheIgnore.php
index fab20ce..a5c558b 100644
--- a/src/StackMiddleware/PageCacheIgnore.php
+++ b/src/StackMiddleware/PageCacheIgnore.php
@@ -39,6 +39,19 @@ class PageCacheIgnore extends PageCache {
     $this->config = $config_factory->get('page_cache_query_ignore.settings');
   }
 
+  /**
+   * Get ignored query params.
+   *
+   * @return array
+   *   Ignored params.
+   */
+  protected function getIgnoredParams() {
+    if (empty($this->ignoredParameters)) {
+      $this->ignoredParameters = $this->config->get('ignored_parameters');
+    }
+    return $this->ignoredParameters;
+  }
+
   /**
    * {@inheritdoc}
    */
@@ -59,19 +72,6 @@ class PageCacheIgnore extends PageCache {
     return $this->cid;
   }
 
-  /**
-   * Get ignored query params.
-   *
-   * @return array
-   *   Ignored params.
-   */
-  protected function getIgnoredParams() {
-    if (empty($this->ignoredParameters)) {
-      $this->ignoredParameters = $this->config->get('ignored_parameters');
-    }
-    return $this->ignoredParameters;
-  }
-
   /**
    * Clear query string.
    *
@@ -82,29 +82,23 @@ class PageCacheIgnore extends PageCache {
    *   The cleared value.
    */
   protected function clear($value) {
-    $value = preg_replace($this->getRegex(), '', $value);
-    $value = str_replace('?&', '?', $value);
-    $value = rtrim($value, '?');
-    return $value;
-  }
+    $request_parts = parse_url($value);
 
-  /**
-   * Generate regex to clear query string.
-   *
-   * @return string
-   *   The regex string.
-   */
-  protected function getRegex() {
-    $param_for_regex = [];
+    if (empty($request_parts['query'])) {
+      return $value;
+    }
+
+    parse_str($request_parts['query'], $request_query);
+
+    // Remove the query arguments that are excluded.
+    $request_query = array_diff_key($request_query, array_flip($this->getIgnoredParams()));
 
-    foreach ($this->getIgnoredParams() as $param) {
-      unset($_REQUEST[$param]);
-      unset($_GET[$param]);
-      $param_for_regex[] = "(?:[&]{0,1}{$param}=[^&]*)";
+    // Rebuild a new URI.
+    $request_uri = $request_parts['path'];
+    if (!empty($request_query)) {
+      $request_uri .= '?' . http_build_query($request_query);
     }
-    $ignore_params_regex = implode('|', $param_for_regex);
-    $regex = "/{$ignore_params_regex}/i";
-    return $regex;
+    return $request_uri;
   }
 
 }
diff --git a/tests/src/Unit/StackMiddleware/PageCacheIgnoreTest.php b/tests/src/Unit/StackMiddleware/PageCacheIgnoreTest.php
index 8361f64..7b4904b 100644
--- a/tests/src/Unit/StackMiddleware/PageCacheIgnoreTest.php
+++ b/tests/src/Unit/StackMiddleware/PageCacheIgnoreTest.php
@@ -37,7 +37,7 @@ class PageCacheIgnoreTest extends UnitTestCase {
       ->getMock();
     $config_factory = $this->getConfigFactoryStub([
       'page_cache_query_ignore.settings' => [
-        'ignored_parameters' => ['gclid', 'msclid'],
+        'ignored_parameters' => ['gclid', 'msclid', 's'],
       ],
     ]);
 
@@ -54,7 +54,7 @@ class PageCacheIgnoreTest extends UnitTestCase {
     $method = $reflection->getMethod('getIgnoredParams');
     $method->setAccessible(TRUE);
 
-    $this->assertArrayEquals(['gclid', 'msclid'], $method->invoke($this->pageCacheIgnore), "PageCacheIgnore::getIgnoredParams matched settings");
+    $this->assertArrayEquals(['gclid', 'msclid', 's'], $method->invoke($this->pageCacheIgnore), "PageCacheIgnore::getIgnoredParams matched settings");
   }
 
   /**
@@ -84,6 +84,7 @@ class PageCacheIgnoreTest extends UnitTestCase {
       ['url/?a=abc&gclid=my-value&msclid=my-value2&b=def', 'url/?a=abc&b=def'],
       ['url/gclid', 'url/gclid'],
       ['url/?a=gclid&msclid=def', 'url/?a=gclid'],
+      ['url/keys?keys=abc&s=123', 'url/keys?keys=abc']
     ];
   }
 
