GithubHelp home page GithubHelp logo

jamesgrobertson / c3-cloudfront-clear-cache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amimoto-ami/c3-cloudfront-clear-cache

0.0 0.0 0.0 7.86 MB

This is simple plugin that clear all cloudfront cache if you publish posts.

Shell 5.12% PHP 94.88%

c3-cloudfront-clear-cache's Introduction

C3 Cloudfront Cache Controller

This is simple plugin that clear all cloudfront cache if you publish posts.

How to install

$ cd /path/to/wordpress/wp-content/plugins
$ git clone [email protected]:amimoto-ami/c3-cloudfront-clear-cache.git
$ cd c3-cloudfront-clear-cache

Adding your configuration through env vars

The plugin can be configured by defining the following environment variables:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • C3_DISTRIBUTION_ID

Filters

Change Invalidation interval

Default interval is 1 minutes.

add_filter('c3_invalidation_interval', function( $interval_minutes ) {
    $custom_interval = 1;
    return $custom_interval;
} );

Change Invalidation retry interval

Default interval is 1 minutes.

add_filter('c3_invalidation_cron_interval', function( $interval_minutes ) {
    $custom_interval = 1;
    return $custom_interval;
} );

Change Invalidation items limit

Default limit is 100.

add_filter( 'c3_invalidation_item_limits', function( $limits ) {
    $custom_limit = 300;
    return $custom_limit;
} );

Customize/Overwrite the invalidation path

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 );

Change or Stop loading bundled AWS SDK (Since v6.0.0)

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;
} );

Logging cron job history(Since v6.0.0)

add_filter( 'c3_log_cron_invalidation_task', '__return_true' );

Local testing

wp-env

Unit test

$ yarn dev
$ yarn test

GitHub Action(WIP)

Using act to execute the workflow in your local.

$ act -P ubuntu-latest=shivammathur/node:latest

c3-cloudfront-clear-cache's People

Contributors

hideokamoto avatar wokamoto avatar yahiru avatar jepser avatar hinaloe avatar renovate-bot avatar jamesgrobertson avatar miya0001 avatar atoutant avatar johnbillion avatar dependabot[bot] avatar mt8 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.