Title: Ignoring query parameters
Last modified: May 20, 2022

---

# Ignoring query parameters

 *  Resolved [tim2022](https://wordpress.org/support/users/tim2022/)
 * (@tim2022)
 * [4 years ago](https://wordpress.org/support/topic/ignoring-query-parameters/)
 * Hi,
 * I’m really impressed with WP Super Cache. Many thanks for all your great work.
 * I’m trying to make a small enhancement so that if that if all of the parameters
   on a URL are in the excluded list then that page is served as a supercache file.
 * At the moment wpsc_remove_tracking_params_from_uri successfully strips all of
   the parameters but because subsequent parameter checks use empty( $_GET ) rather
   than checking $wp_cache_request_uri, the page fails the supercache test.
 * Putting:
 *  if( true == empty( $query ) ) {
    $_GET = []; }
 * at the end of function wpsc_remove_tracking_params_from_uri seems to do the trick
   but I’d like to find a clean way of achieving this with a proper plugin without
   modifying the main code.
 * Any pointers as to how I should do this would be greatly appreciated, as I can’t
   seem to find a good hook at the moment.
 * Kind regards,
 * Tim

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [4 years ago](https://wordpress.org/support/topic/ignoring-query-parameters/#post-15678989)
 * Thanks Tim for the suggestion. I’ll give it a look.
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [4 years ago](https://wordpress.org/support/topic/ignoring-query-parameters/#post-15705388)
 * In the foreach loop on `$wpsc_tracking_parameters as $param_name` if you add 
   the following line (after line 48) this should do the same, but it’s better in
   case not all parameters are removed:
    `unset( $_GET[ $param_name ] );`
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [4 years ago](https://wordpress.org/support/topic/ignoring-query-parameters/#post-15709789)
 * It was more complicated than that. I had to remove the query vars from REQUEST_URI
   too if GET was empty. Fixed in [https://github.com/Automattic/wp-super-cache/pull/818](https://github.com/Automattic/wp-super-cache/pull/818)
 *  Thread Starter [tim2022](https://wordpress.org/support/users/tim2022/)
 * (@tim2022)
 * [4 years ago](https://wordpress.org/support/topic/ignoring-query-parameters/#post-15719908)
 * Hi Donncha,
 * Many thanks for looking into that for me. I’ve tested the new fix and unfortunately
   it’s causing me problems. The problem is with this line:
 *     ```
       if ( empty( $_GET ) ) {
           $_SERVER['REQUEST_URI'] = strtok( $_SERVER['REQUEST_URI'], '?' );
       }
       ```
   
 * as it removes the parameters completely from the request rather than just removing
   them from the caching decision. In my case I still need the parameters active,
   as there’s javascript on the page that needs them, but the page that can be served
   up can still be a supercache page.
 * Rather than change `$_SERVER['REQUEST_URI']`, would it be possible to test `$
   wp_cache_request_uri` in `wpsc_is_get_query()` e.g.
 *     ```
       function wpsc_is_get_query() {
       	static $is_get_query = null;
       	global $wp_cache_request_uri;
   
       	if ( null === $is_get_query ) {
       		$request_uri = parse_url( $wp_cache_request_uri );
       		$is_get_query = $request_uri && ! empty( $request_uri['query'] );
       	}
   
       	return $is_get_query;
       }
       ```
   
 * and then the functionality would be the same as before i.e. it passes the parameters
   through but makes the caching decision on `$wp_cache_request_uri`.
 * Many thanks,
 * Tim
    -  This reply was modified 4 years ago by [tim2022](https://wordpress.org/support/users/tim2022/).
    -  This reply was modified 4 years ago by [tim2022](https://wordpress.org/support/users/tim2022/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Ignoring query parameters’ is closed to new replies.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=3506220)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [tim2022](https://wordpress.org/support/users/tim2022/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/ignoring-query-parameters/#post-15719908)
 * Status: resolved