• Resolved gbruzzo

    (@gbruzzo)


    Hello there,

    hoping you may be able to help.

    Our shop page can be filtered by different parameters
    format (an attribute)
    price (min / max)
    artist_involved (a custom taxonomy)

    The queries result in URL strings such as

    https://www.rarenoiserecords.com/releases/?min_price=5&max_price=10&filter_format=cd&query_type_format=or&artists_involved_filter=animation

    I would like sg optimizer not to page-cache any URL containing any the following query strings (no page caching of the URL whether only one or multiple of these strings are included in the URL, whatever the order).

    min_price
    max_price
    artist_involved_filter (way more than 100 involved artists)

    so https://www.rarenoiserecords.com/releases/?filter_format=cd;
    should be cached, but
    so https://www.rarenoiserecords.com/releases/?filter_format=vinyl&artists_involved_filter=adam-rudolph;
    should not

    (Please note cd, vinyl are two of several possible formats; adam-rudoph is one of hundreds of involved artists : I would like exclusion rules to be of the form ‘=*’, covering all artists or formats, or prices for that matter).

    I attempted two solutions, unsuccesfully:

    1. I asked optimizer not to cache URLs with *artists_involved_filter=* in the plugin dashboard – the plugin saves this as a rule not to cache URLs with /*artists_involved_filter=* – this results in no page being cached

    2. I tried adding

    add_filter( 'sgo_bypass_query_params', 'add_sgo_bypass_query_params');
    function add_sgo_bypass_query_params( $bypass_query_params ) {
        // Add custom query params, that will skip the cache.
        $bypass_query_params[] = 'artists_involved_filter=';
    
        return $bypass_query_params;
    }

    in functions.php, but pages with that string are still being cached.

    What am I doing wrong?

    Thank you in advance for any comments/suggestions

    Giacomo Bruzzo

    • This topic was modified 2 years, 2 months ago by gbruzzo.
    • This topic was modified 2 years, 2 months ago by gbruzzo.
    • This topic was modified 2 years, 2 months ago by gbruzzo.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Plamen M

    (@plamenm)

    Hello @gbruzzo ,

    You can learn how to exclude URLs from the caching at this official article:

    https://www.siteground.com/tutorials/wordpress/sg-optimizer/supercacher/#Exclude_URLs_from_Caching

    In your case, you should create 3 separate rules in the “Exclude URLs from Caching” section of the plugin:

    *min_price*
    *max_price*
    *artist_involved_filter*

    Then purge all the available caches and test the filtered URL anew. If you continue experiencing issues, please post a support ticket request through your SiteGround User Area so that we can check the case further: https://stgrnd.co/contactus

    Best regards,
    Plamen.M
    Tech Support Team
    SiteGround.com

    • This reply was modified 2 years, 2 months ago by Plamen M.
    Thread Starter gbruzzo

    (@gbruzzo)

    Dear Plamen,

    thank you for confirming that the first approach used was in fact the correct one (minus the ‘=’).

    For the sake of better understanding, could you please explain how

    add_filter( 'sgo_bypass_query_params', 'add_sgo_bypass_query_params');
    function add_sgo_bypass_query_params( $bypass_query_params ) {
        // Add custom query params, that will skip the cache.
        $bypass_query_params[] = 'query_param';
    
        return $bypass_query_params;
    }

    and

    add_filter( 'sgo_ignored_query_params', 'add_sgo_ignored_query_params');
    function add_sgo_ignored_query_params( $ignored_query_params ) {
        // The query parameters which will be ignored.
        $ignored_query_params[] = 'query_param';
        $ignored_query_params[] = 'query_param2';
    
        return $ignored_query_params;
    }

    work?

    Thanks again in advance

    Giacomo Bruzzo

    • This reply was modified 2 years, 2 months ago by gbruzzo.
    Plugin Support Plamen M

    (@plamenm)

    Thank you for the update. In your reply you mentioned that you used:

    *artists_involved_filter=*

    and in my suggestion I advised you to skip the equal sign, which is treated as a special character. Please, give this a try.

    The difference between those filters is:

    sgo_bypass_query_params
    if we add a specific parameter to the filter we will be able to use this parameter and check the page from the origin server directly no matter if it is being cached or not. Example:
    domain.com/someurl/ – cached page – we access the cached version
    domain.com/someurl&customparam – See the same page but seen directly from the origin server ( cache bypassed )

    add_sgo_ignored_query_params
    This filter will tell the plugin that pages with it should not be cached at all.

    Som in your use case, you should use So the user should use the add_sgo_ignored_query_params filter instead.

    If you need further assistance, let’s continue this discussion through a support ticket through your SiteGround User area, so that we can check the case on your site panel directly and check the relevant server logs as well.

    Regards,
    Plamen.M
    Tech Support Team
    SiteGround.com

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to exclude URLs with specific query strings’ is closed to new replies.