Support » Plugin: WP REST Cache » Ignore query string parameters

  • Resolved nilsnolde

    (@nilsnolde)


    Hi,
    great plugin! And I’d love to use it for our WooCommerce store. Adding cache to custom endpoints worked like a charm already:)

    However, due to various circumstances we have to provide the oAuth 1.0 parameters for WC in the query string parameters. Which also means that EVERY call to our database has a different signature in the query string, resulting in a different cache for every call.

    Is there a standard way to ignore the query string parameters for a custom endpoint? I’d really like to avoid to hack the s*** out of this lovely plugin;)

Viewing 6 replies - 1 through 6 (of 6 total)
  • nilsnolde

    (@nilsnolde)

    And where would we find the source code repository? Is it this here: https://github.com/RedCastor/wp-rest-cache?

    Plugin Author Richard Korthuis

    (@rockfire)

    Hi @nilsnolde

    Thank you for using our plugin!

    At this point we do not have an option to ignore specific query string parameters. However you use case makes it totally understandable to want to have that option, so we will add a filter for it. I will let you know once we have implemented and released it.

    About the source code repository: At the moment it is not publicly accessible (it is in a private Bitbucket repository), but we are considering making it public. The repository you found is from someone who created his own repository containing the code of our plugin. However it is very outdated, so I don’t recommend using it.

    Great, thanks so much @rockfire for considering add this to the plugin.

    I’d highly recommend to put it on Github, I would have put an issue and asked if I can PR it in. Apart from Github’s respectable SEO, WordPress’ GPL etc.

    At this point we do not have an option to ignore specific query string parameters.

    And maybe I’m misunderstanding this, but is there an option then to ignore all query string params, not just specific ones?

    Let me know if/when you made the repo public, my offer still stands:)

    Plugin Author Richard Korthuis

    (@rockfire)

    Hi @nilsnolde

    We just release a new version of our plugin which includes a filter to ignore specific query string parameters. If you would for instance have a parameter wprc_param in your query string you would like to have ignore, you can do so like this:

    /**
     * Do not use the 'wprc_param' query parameter in the cacheable query string.
     */
    function wprc_set_uncached_parameters( $uncached_parameters ) {
    	$uncached_parameters[] = 'wprc_param';
    
    	return $uncached_parameters;
    }
    
    add_filter( 'wp_rest_cache/uncached_parameters', 'wprc_set_uncached_parameters', 10, 1 );

    Please let us know if this works for you!

    And no, there isn’t an option to ignore all query parameters.

    Sorry for the late reply, just got around looking at this again.

    And great news @rockfire : it works as advertised!! Thanks so much for the quick turnaround! Always happy to see dedicated plugin maintainers, unfortunately not that common in the WP world.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.