Description
ByteCoreStack – Cache Invalidation for Amazon CloudFront is a dedicated CloudFront cache invalidation plugin for WordPress, built around one job and doing it well: keeping your Amazon CloudFront CDN cache in sync with your content. If your site runs behind a CloudFront distribution, this plugin gives you complete control over cache invalidation — a one-click manual purge, automatic CloudFront cache clearing the moment content changes, or a recurring scheduled cache clear — all from your WordPress admin, with no AWS Console visits required.
This plugin speaks the CloudFront REST API directly using AWS Signature Version 4 request signing, and is purpose-built around how CloudFront invalidations actually work: targeted path invalidation instead of blanket wipes, batching to protect your invalidation quota, and a live invalidation history pulled straight from the CloudFront API.
Features
- Built specifically for Amazon CloudFront — it signs and sends real CloudFront
CreateInvalidation,GetDistribution,ListInvalidations, andGetInvalidationAPI requests directly. - Smart, targeted CloudFront cache invalidation — auto-clear invalidates the specific permalink, term archives, post-type archive, and homepage affected by a change, instead of always purging the entire distribution.
- No stale content after publishing — automatic cache invalidation on publish, update, unpublish, trash, term edits, menu changes, widget changes, and attachment deletion means visitors don’t keep seeing outdated cached pages.
- Set-and-forget scheduled cache clearing — interval, weekly, or monthly CloudFront cache clears with a live countdown, so you always know when the next invalidation runs.
- Invalidation batching — rapid successive content changes are merged into a single deferred invalidation instead of firing one CloudFront API call per save, protecting your monthly invalidation quota.
- Live Invalidation History — a dedicated tab lists your recent CloudFront invalidations straight from the AWS API, with per-invalidation path details, pagination, and a “show per page” control. Nothing is cached or stored locally.
- Credentials never touch the database — your AWS access key and secret live in wp-config.php only, never stored in wp_options, never exposed in the admin UI, REST API, or AJAX responses.
- IAM instance-role support — running on an EC2 instance with an IAM role attached? Skip static AWS keys entirely; the plugin automatically fetches temporary credentials from the EC2 instance metadata service.
- One-click connection and permission diagnostics — “Test Connection” verifies your credentials and distribution ID instantly, and “Check Permissions” tests each required IAM action individually so a misconfigured policy is diagnosable at a glance instead of guessing which permission is missing.
- WP-CLI support — script CloudFront cache purges from the command line for CI/CD deploy pipelines:
wp bcs-cfm flush allorwp bcs-cfm flush <path>.
Key Features
Manual CloudFront Cache Clearing
* Purge your entire CloudFront distribution in one click
* Purge a single specific URL or path without touching the rest of the cache
* Per-user rate limiting prevents accidental repeated clicks from burning through your AWS invalidation quota
* Instant success/failure feedback with clear, actionable AWS error messages
Automatic CloudFront Cache Invalidation
* Fires on publish, update, unpublish/trash, and permanent post deletion
* Targets the exact permalink, taxonomy term archives, post-type archive, and homepage affected — not a blanket /* wipe
* Falls back to a full distribution invalidation only when a single change touches more than 10 paths
* Also triggers on attachment/media deletion, taxonomy term edits, nav menu changes, and active widget changes
* Choose exactly which post types (posts, pages, custom post types, WooCommerce products, etc.) trigger auto-clear
* Rapid successive changes are automatically batched into a single deferred invalidation via WP-Cron
Scheduled CloudFront Cache Clearing
* Interval-based (every 5 minutes up to every 24 hours), weekly, or monthly scheduling
* Choose the exact time, day of week, or day(s) of month
* Live countdown timer to the next scheduled cache clear
* Fully timezone-aware, using your WordPress site’s configured timezone
Invalidation History
* Lists your most recent CloudFront invalidations, fetched live from the AWS API — nothing is stored in your database
* Expand any invalidation inline to see its full path list and status
* Built-in pagination with a configurable “show per page” control
AWS Connection & Permission Tools
* “Test Connection” — verifies your access key, secret key, and distribution ID against the live CloudFront API
* “Check Permissions” — tests GetDistribution, ListInvalidations, and GetInvalidation individually and reports exactly which IAM action is missing
* Actionable, specific error messages for common misconfigurations (wrong distribution ID, bad signature/credentials, insufficient IAM permissions)
Flexible, Secure Configuration
* Credentials read exclusively from wp-config.php constants — never written to the database
* Optional IAM instance-role credential fallback for EC2-hosted sites, no static keys required
* A WordPress Dashboard widget summarizing AWS status, Auto-Clear/Schedule state, next scheduled run, and last cleared time
* WP-CLI command for scripted/CI-driven cache purges
Perfect For
- WordPress sites, blogs, and publishers hosted behind an Amazon CloudFront CDN distribution
- Agencies and freelance developers managing CloudFront cache invalidation across multiple client sites
- News and publishing sites that need fresh content delivered fast after every update
- WooCommerce stores and membership sites with frequently changing content, stock, or pricing
- Developers who want automated, hands-off CloudFront cache invalidation instead of manual AWS Console purges
- Teams who want CI/CD pipelines to trigger a CloudFront cache purge on deploy via WP-CLI
Requirements
- An AWS account with an active Amazon CloudFront distribution
- AWS Access Key ID and Secret Access Key with CloudFront permissions (or an EC2 instance with an IAM role attached)
- WordPress 5.3 or higher
- PHP 7.4 or higher
Documentation
Full setup instructions and documentation available at https://bytecorestack.com/plugins/cloudfront-manager
External Services
This plugin connects to the AWS CloudFront API to perform CDN cache management operations, and — only as a fallback described below — to the EC2 instance metadata service.
AWS CloudFront API
This plugin sends requests to the AWS CloudFront REST API endpoint:
https://cloudfront.amazonaws.com/2020-05-31/distribution/{distributionId}/...
covering invalidation creation, invalidation listing/detail lookups, and distribution status checks.
What data is sent:
- Your CloudFront distribution id (stored locally in wp-config.php)
- A request signed with your AWS credentials using AWS Signature Version 4 — no personal data, user data, or site content is transmitted beyond the distribution id and the invalidation paths
When data is sent:
- When you manually click “Purge Entire Distribution” or “Purge a Specific URL”
- When a post/page is published, updated, unpublished, or deleted; when a term is edited; or when a nav menu or the active widgets change (if Auto-Clear is enabled)
- On a recurring schedule (if Scheduled Auto-Clear is enabled)
- When you click “Test Connection” or “Check Permissions”, or open the Invalidation History tab
AWS EC2 Instance Metadata Service (conditional fallback)
Only if AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY are not defined in wp-config.php, the plugin makes a local network request to http://169.254.169.254 (the standard EC2 instance metadata endpoint, only reachable from within an EC2 instance) to retrieve temporary credentials from an attached IAM role. No data leaves your own EC2 instance for this request. If static credentials are configured, this request is never made.
AWS Terms of Service: https://aws.amazon.com/service-terms/
AWS Privacy Policy: https://aws.amazon.com/privacy/
Support
For support, feature requests, or bug reports, please visit:
* Plugin page: https://bytecorestack.com/plugins/cloudfront-manager
* Author website: https://bytecorestack.com/
Privacy Policy
This plugin does not collect, store, or transmit any user data. All AWS credentials are stored locally in your wp-config.php file and are only used to communicate with the AWS CloudFront API for cache management operations. See the External Services section above for full details on what is sent to AWS.
Credits
Developed by ByteCore Stack.
This plugin bundles the DM Sans and DM Mono fonts, designed by Colophon Foundry / Indian Type Foundry and distributed by Google Fonts (https://fonts.google.com/specimen/DM+Sans and https://fonts.google.com/specimen/DM+Mono), licensed under the SIL Open Font License, Version 1.1 (GPL-compatible).
License
This plugin is licensed under the GPLv2 or later.
Screenshots






Installation
From WordPress Admin
- Go to Plugins > Add New
- Search for “ByteCoreStack – Cache Invalidation for Amazon CloudFront”
- Click “Install Now” and then “Activate”
- Configure your AWS credentials in wp-config.php
- Go to Settings > CloudFront Manager to manage your CloudFront cache
Manual Installation
- Download the plugin ZIP file
- Upload to /wp-content/plugins/ directory
- Extract the ZIP file
- Activate the plugin through WordPress admin
- Configure AWS credentials (see Configuration section)
Configuration
Add these constants to your wp-config.php file:
define('AWS_ACCESS_KEY_ID', 'your_access_key_here');
define('AWS_SECRET_ACCESS_KEY', 'your_secret_key_here');
define('CLOUDFRONT_DISTRIBUTION_ID', 'your_distribution_id');
Note: AWS_DEFAULT_REGION is not needed — CloudFront’s control-plane API is a single global endpoint always signed with region us-east-1, regardless of where your site or distribution lives.
Running on an EC2 instance with an IAM role attached? You can skip AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY entirely — the plugin automatically uses the instance role’s temporary credentials. CLOUDFRONT_DISTRIBUTION_ID is still required.
Finding Your Distribution ID: 1. Log in to the AWS CloudFront console 2. Go to Distributions 3. Find your distribution and copy its ID (e.g. E2SF6Q2IFE653G)
Creating AWS Credentials:
1. Go to the AWS IAM console
2. Create a new user or use an existing one
3. Attach the required CloudFront permissions (see IAM Permissions on the Configuration tab: cloudfront:CreateInvalidation, cloudfront:GetDistribution, cloudfront:ListInvalidations, cloudfront:GetInvalidation)
4. Generate access keys
5. Add the keys to wp-config.php
Verifying Your Setup: 1. Open Settings > CloudFront Manager > Configuration tab 2. Click “Test Connection” to confirm your credentials and distribution ID are valid 3. Click “Check Permissions” to confirm each required IAM action is granted
FAQ
-
How do I clear my AWS CloudFront CDN cache from WordPress?
-
Install and activate this plugin, add your AWS credentials to wp-config.php, then go to Settings > CloudFront Manager and click “Purge Entire Distribution.” No need to log in to the AWS Console at all.
-
What is AWS CloudFront?
-
Amazon CloudFront is AWS’s content delivery network (CDN) service that caches your website content at edge locations worldwide, making your site faster for visitors globally. This plugin manages CloudFront cache invalidation specifically — clearing cached content so visitors see your latest updates.
-
Do I need an AWS account?
-
Yes, you need an AWS account with an active Amazon CloudFront distribution and appropriate IAM permissions.
-
How do I get my AWS credentials?
-
Create AWS credentials (an Access Key ID and Secret Access Key) from the AWS IAM console. Make sure the credentials have permission to manage CloudFront invalidations — see the Configuration section above for the exact IAM actions required.
-
Can I run this without static AWS keys?
-
Yes, if your WordPress site runs on an EC2 instance with an IAM role attached. Leave AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY undefined in wp-config.php, and the plugin will automatically fetch temporary credentials from the EC2 instance metadata service. You still need to define CLOUDFRONT_DISTRIBUTION_ID.
-
How do I know if my AWS credentials and IAM permissions are set up correctly?
-
Use “Test Connection” on the Configuration tab to verify your access key, secret key, and distribution ID against the live CloudFront API. Use “Check Permissions” to test each required IAM action individually (GetDistribution, ListInvalidations, GetInvalidation) and see exactly which one is missing if something’s misconfigured.
-
Is this plugin secure?
-
Yes. The plugin uses AWS Signature Version 4 for secure request signing, credentials are stored only in wp-config.php (never in the WordPress database), and no plugin option or AJAX response ever exposes your secret key. All AJAX requests are protected with WordPress nonces and a
manage_optionscapability check. -
What’s the difference between Amazon CloudFront and Amazon Lightsail CDN?
-
Amazon CloudFront is AWS’s standalone, full-featured CDN, while Lightsail CDN is the simplified content delivery network bundled with Lightsail distributions. This plugin is built specifically for CloudFront distributions — if you’re using Lightsail CDN instead, you’ll need a Lightsail-specific plugin.
-
Can I automatically clear the cache when I publish or update a post?
-
Yes. Enable Auto-Clear and choose which post types (posts, pages, WooCommerce products, or any custom post type) should trigger an automatic, targeted CloudFront cache invalidation whenever they’re published, updated, unpublished, or trashed.
-
Does auto-clear invalidate my whole distribution every time?
-
No. Auto-Clear invalidates only the specific paths affected — the post’s own permalink, its taxonomy term archives, its post-type archive, and the homepage — instead of a blanket full-site purge. A full “/*” invalidation only happens if a single change touches more than 10 paths at once, or when you explicitly click “Purge Entire Distribution.”
-
Can I schedule cache clears at specific times?
-
Yes. The plugin supports interval (every 5 minutes up to every 24 hours), weekly, and monthly scheduling with customizable times. Choose the exact time and day/date for cache clearing, with a live countdown to the next run, fully aware of your WordPress site’s timezone.
-
Can I see a history of my CloudFront invalidations?
-
Yes. The Invalidation History tab lists your most recent invalidations, fetched live from the CloudFront API, with pagination and a per-invalidation path-list detail view. Nothing is stored in your WordPress database.
-
What happens if cache clearing fails?
-
The plugin displays a specific, actionable error message explaining what went wrong — for example, an incorrect distribution ID, a signature/credentials mismatch, or a missing IAM permission. Use “Test Connection” and “Check Permissions” to diagnose issues before they happen.
-
Will this slow down my site?
-
No. Cache invalidation requests only fire when you manually clear cache, when content changes (if Auto-Clear is enabled), or during a scheduled clear — never on regular visitor page loads.
-
Does this work with WooCommerce?
-
Yes. WooCommerce registers products as a custom post type, so you can enable Auto-Clear for products (and product variations) to keep your storefront’s CDN cache fresh whenever inventory, pricing, or product details change.
-
Can I trigger a cache purge from the command line or a CI/CD pipeline?
-
Yes. The plugin includes WP-CLI support: run
wp bcs-cfm flush allfor a full distribution purge, orwp bcs-cfm flush /some/path,/another/pathto invalidate specific paths — handy for firing a CloudFront cache purge automatically after a deploy. -
Are there costs to running CloudFront invalidations?
-
AWS grants 1,000 free path invalidations per month; a full “/*” invalidation only counts as a single path. Beyond that allowance, standard CloudFront invalidation pricing applies. The plugin’s targeted, batched invalidations are designed to make efficient use of this quota.
-
Does this work with multisite?
-
Yes, the plugin is compatible with WordPress multisite installations. Each site can have its own AWS credentials, distribution ID, auto-clear settings, and cache clearing schedule.
Reviews
There are no reviews for this plugin.
Contributors & Developers
“ByteCoreStack – Cache Invalidation for Amazon CloudFront” is open source software. The following people have contributed to this plugin.
ContributorsTranslate “ByteCoreStack – Cache Invalidation for Amazon CloudFront” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Changelog
1.0.0
- Initial release
- Manual cache invalidation, including a full distribution purge and single-URL/path purges
- Automatic cache invalidation on publish/update, targeting the post’s own permalink, its term archives, its post-type archive, and the homepage instead of always purging the whole distribution (falls back to a full “/*” invalidation only when a post touches more than 10 paths)
- Automatic invalidation when a post leaves publish status (trashed, reverted to draft/pending/private), when an attachment is deleted, when a term is edited, and when a nav menu or the active widgets change
- Rapid successive changes are batched into a single deferred invalidation (fired shortly after via WP-Cron) instead of firing one AWS API call per save
- Scheduled cache invalidation (interval, weekly, monthly) with a live countdown timer, using your WordPress timezone
- Support for custom post types
- An Invalidation History tab listing recent invalidations live from the CloudFront API, with a per-invalidation path-list detail view and pagination — nothing is stored locally
- A “Check Permissions” button that tests each required IAM action individually and reports exactly which one is missing, instead of failing generically
- An IAM instance-role credential fallback (EC2 instance metadata, IMDSv2 with IMDSv1 fallback) for sites hosted on EC2 with an attached IAM role — no static AWS keys required in wp-config.php in that case
- A WordPress Dashboard widget showing AWS status, Auto-Clear/Schedule state, next scheduled run, and last cleared time at a glance
- WP-CLI support:
wp bcs-cfm flush all/wp bcs-cfm flush <path[,path...]> - A per-user rate limit on manual purge actions, to prevent accidental repeated clicks from burning through your AWS invalidation quota
- AWS error messages translated into actionable guidance for common failure modes (bad distribution ID, bad signature/credentials, insufficient IAM permissions)
- Comprehensive AWS error reporting
- Clean, modern admin interface
- Full WordPress coding standards compliance
