• Resolved asafm7

    (@asafm7)


    Hello.

    It seems the plugin doesn’t cache pages with query variables in the URL.

    In most cases it makes sense. But in some cases, query variables should be ignored. For example, in the case of Google Analytics UTM parameters.

    Can it be done with the plugin?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter asafm7

    (@asafm7)

    Okay, I found this filter, which should do it:

    wpo_cache_ignore_query_variables

    I’ve tried using this code, but it isn’t being invoked:

    add_filter('wpo_cache_ignore_query_variables', 'filter_wpo_cache_ignore_query_variables');
    
    function filter_wpo_cache_ignore_query_variables($exclude_variables) {
        $exclude_variables[] = 'noedgecache';
    
        return $exclude_variables;
    }

    It might be a sequence issue. functions.php might be too late. But I tried moving to code to a must-use plugin and it didn’t help. I don’t think we can go earlier than that…

    Plugin Support vupdraft

    (@vupdraft)

    To cache URL’s with query string variables you would need a disk caching and memory-based caching like Redis or Memcached.
    The accepted query strings field is used to remove that part from the query string and then check if the URL equals a page that is cached. So it doesn’t allow to create of a new version of the page to be cached, it actually just says the pages are equal, so you should load the cached page

    Plugin Support wpmansour

    (@wpmansour)

    @asafm7 Try this code:

    function custom_wpo_cache_ignore_query_variables($exclude) {
        $new_variables = array('utm_campaign', 'utm_medium', 'utm_source', 'utm_content', 'utm_term', 'your_query_var1', 'your_query_var2'); 
        $exclude = array_merge($exclude, $new_variables);
        return $exclude;
    }
    add_filter('wpo_cache_ignore_query_variables', 'custom_wpo_cache_ignore_query_variables');

    Please replace 'your_query_var1' and 'your_query_var2' with the actual query parameters you want WP-Optimize to ignore. Add this code to your theme’s functions.php file or a custom plugin.

    Let us know if you still face any issues. Thanks!

    Thread Starter asafm7

    (@asafm7)

    I will check it out. Thanks, @wpmansour.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Ignoring some query variables’ is closed to new replies.