kodansha/wack-cloudfront-invalidation
Composer 安装命令:
composer require kodansha/wack-cloudfront-invalidation
包简介
Invalidate CloudFront caches when a post is published or updated.
关键字:
README 文档
README
WACK CloudFront Invalidation is a WordPress plugin that helps you to run invalidation on CloudFront after a post is published or updated.
It is designed to work with the WACK Stack, but can be used with any WordPress installation that uses CloudFront as a CDN.
How it works
This plugin triggers invalidation for published content updates by using:
save_postrest_after_insert_{post_type}(forpostand public custom post types)
It skips autosaves, revisions, and unpublished states such as draft and
auto-draft.
Installation
- Requires PHP 8.2 or later
- Requires WordPress 6.7 or later
- Requires Composer
Using Composer
composer require kodansha/wack-cloudfront-invalidation
Note
This plugin is not available on the WordPress.org plugin repository. The only installation method currently available is through Composer.
Configuration
AWS credentials
WACK CloudFront Invalidation uses AWS SDK for PHP to send invalidation requests to CloudFront, so you need to configure AWS credentials. Please refer to the AWS SDK for PHP documentation for more information on how to set up credentials.
CloudFront Distribution ID
You can configure a CloudFront Distribution ID in either of the following ways:
- Set
WACK_CF_INV_DISTRIBUTION_IDinwp-config.php(or equivalent) - Enter it in the plugin settings page (
WACK Stack>WACK CF Inv)
define('WACK_CF_INV_DISTRIBUTION_ID', 'YOUR_CLOUDFRONT_DISTRIBUTION_ID');
Important
If WACK_CF_INV_DISTRIBUTION_ID is defined, it takes precedence over the value stored in the database.
Note
This plugin supports only one CloudFront Distribution ID.
Invalidation Path Settings
After installing the WACK CloudFront Invalidation plugin, a settings page is added to the WordPress admin menu under WACK Stack > WACK CF Inv.
In this settings page, you can configure CloudFront invalidation paths for each post type.
Important
To specify multiple paths, list them separated by line breaks. Empty lines will be ignored.
You can use the following placeholders in each path:
%id%: Replaced with the post ID%slug%: Replaced with the post slug (falls back to post ID when slug is empty)
wack_cf_inv_{post_type}_paths filter
This plugin allows you to customize the CloudFront invalidation paths per post type using a filter.
The following filter is applied before issuing a CloudFront invalidation:
$paths = apply_filters('wack_cf_inv_' . $post->post_type . '_paths', $paths, $post);
{post_type}: Replace with your custom post type (e.g.,post,news, etc.).$paths: Array of paths determined by the post type and the plugin settings.$post: TheWP_Postobject being processed.
Example
To add the homepage (/) to the invalidation paths for the post post type,
add the following to your theme’s functions.php or a custom plugin:
add_filter('wack_cf_inv_post_paths', function($paths, $post) { $paths[] = '/'; return $paths; }, 10, 2);
This filter allows you to modify or extend the list of paths to be invalidated for each post type, providing flexible cache control.
Tip
If you want to modify or extend the list of paths for the news post type,
use wack_cf_inv_news_paths instead of wack_cf_inv_post_paths.
Tips
WACK_CF_INV_DRY_RUN constant
Dry Run can be configured either by constant (WACK_CF_INV_DRY_RUN) or from
the plugin settings page.
When WACK_CF_INV_DRY_RUN is defined, its value takes precedence over the
database setting.
If Dry Run is enabled, the actual CloudFront invalidation execution will be skipped, and only log output will be performed.
You can use this for testing behavior in development environments.
WACK Log integration
If you have the WACK Log plugin installed, various logs from WACK CloudFront Invalidation will be output to standard output using WACK Log.
kodansha/wack-cloudfront-invalidation 适用场景与选型建议
kodansha/wack-cloudfront-invalidation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 376 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「wordpress」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kodansha/wack-cloudfront-invalidation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kodansha/wack-cloudfront-invalidation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kodansha/wack-cloudfront-invalidation 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Plugin for YOURLS. Default tools to use in some laemmi plugins
Must-use plugin integrating WordPress with the Upsun platform: environment awareness, router-cache friendliness, safe preview clones, deploy migrations, Site Health checks, and a wp upsun CLI command.
Allows polling user for event dates and times.
Support swipe touch gestures to navigate in paginated lists and on Tidypics image pages.
Add a postscript to every email notification sent out to users.
统计信息
- 总下载量: 376
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2025-04-14