how to exclude URLs with specific query strings
-
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
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
- The topic ‘how to exclude URLs with specific query strings’ is closed to new replies.