This is simple plugin that clear all cloudfront cache if you publish posts.
$ cd /path/to/wordpress/wp-content/plugins
$ git clone [email protected]:amimoto-ami/c3-cloudfront-clear-cache.git
$ cd c3-cloudfront-clear-cache
The plugin can be configured by defining the following environment variables:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
C3_DISTRIBUTION_ID
Default interval is 1 minutes.
add_filter('c3_invalidation_interval', function( $interval_minutes ) {
$custom_interval = 1;
return $custom_interval;
} );
Default interval is 1 minutes.
add_filter('c3_invalidation_cron_interval', function( $interval_minutes ) {
$custom_interval = 1;
return $custom_interval;
} );
Default limit is 100.
add_filter( 'c3_invalidation_item_limits', function( $limits ) {
$custom_limit = 300;
return $custom_limit;
} );
Using the c3_invalidation_items
filter, we can update the invalidation path.
add_filter( 'c3_invalidation_items', function($items){
return array('/*');
});
add_filter( 'c3_invalidation_items', function( $items, $post ) {
if ( 'should-overwritten' === $post->post_name) {
return ['/slug-overwritten'];
}
return $items;
}, 10, 2 );
Use c3_aws_sdk_path
filter, to relace the AWS SDK library path.
add_filter( 'c3_aws_sdk_path', function () {
return 'YOUR/CUSTOM/AWS/SDK/ENTRY/POINT.php';
} );
If return null, the plugin will not load bundled AWS SDK.
add_filter( 'c3_aws_sdk_path', function () {
return null;
} );
add_filter( 'c3_log_cron_invalidation_task', '__return_true' );
$ yarn dev
$ yarn test
Using act to execute the workflow in your local.
$ act -P ubuntu-latest=shivammathur/node:latest