• Resolved fkoomek

    (@fkoomek)


    Hello.
    I am using the basic caching method and have caching Query strings option enabled.
    Now, I would like to exclude a certain query string (Search results) from caching. The URL syntax is:
    https://www.liberlapidum.com/cs/?s=emerald&post_type=product
    where the emerald is an example of a searched word.
    I tried to write down to “Never cache the following pages:” box things like:
    /?s=
    or
    /?s=*/
    But this always excludes completely all query strings.
    How do I exclude only search results?
    Thank you.

    • This topic was modified 5 years, 2 months ago by fkoomek.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @fkoomek

    Thank you for your inquiry and I am happy to assist you with this.
    There is no option to exclude specific queries from Page Cache. You should disable “Cache URIs with query string variables” add the page URL to the “Accepted query strings” field.
    Thank you!

    Thread Starter fkoomek

    (@fkoomek)

    Thank you. I solved it by disabling W3 Total cache when the query string is /?=.
    So I wrote to mu-plugins

    add_filter(‘option_active_plugins’, ‘lg_disable_plugin’);

    function lg_disable_plugin($plugins)
    {
    if (strpos($_SERVER[‘REQUEST_URI’], ‘/?s=’) !== false) {
    $key = array_search(‘w3-total-cache/w3-total-cache.php’, $plugins);
    if (false !== $key)
    unset($plugins[$key]);
    }
    return $plugins;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘exclude certain query string’ is closed to new replies.