1. Go to this page and download the library: Download valu/wp-graphql-cache library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
/**
* Register cache to a 'menus' zone
*/
CacheManager::register_graphql_field_cache([
'zone' => 'menus', // 👈
'query_name' => 'MyBigQuery',
'field_name' => 'menuItems',
'expire' => 120, // sec
]);
/**
* Clear the zone 'menus' when the menus are updated
*/
add_action('wp_update_nav_menu', function () {
CacheManager::clear_zone('menus');
});
use WPGraphQL\Extensions\Cache\Backend\FileSystem;
add_filter('graphql_cache_backend', function () {
return new FileSystem( [
'base_directory' => '/custom/path',
'directory_permissions' => '0770',
'file_permissions' => '0660',
] );
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.