-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
e.g When I activated smart cache, customer query was getting cached. I want to be able to exclude specific queries so that they are never cached simply by sending a variable in the request or having the specified queries in settings page. i created this snippet as a hack. If a more advanced php person can solve this in better way with new release, that would be great.
So every time I request it will toggle the cache. However this isn't ideal.
add_action( 'init', function() {
if (
$_SERVER['REQUEST_METHOD'] === 'POST' &&
isset( $_REQUEST['disable_cache'] )
) {
if ( is_plugin_active( 'wp-graphql-smart-cache/wp-graphql-smart-cache.php' ) ) {
add_filter( 'graphql_get_setting_section_field_value', function( $value, $default, $option_name, $section_fields, $section_name ) {
if ( $option_name === 'cache_toggle' ) {
return false;
}
return $value;
}, 10, 5 );
}
}
} );
Metadata
Metadata
Assignees
Labels
No labels