定制 augustash/wordpress-cache-protection 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

augustash/wordpress-cache-protection

Composer 安装命令:

composer require augustash/wordpress-cache-protection

包简介

WordPress equivalent of drupal_cache_protection. Strips/redirects tracking params so Varnish caches canonical URLs, augments robots.txt with bot-throttling rules, and exposes filters for site-specific extension.

README 文档

README

Protects WordPress page cache from fragmentation by tracking parameters and bot abuse.

Install

ddev composer require augustash/wordpress-cache-protection && ddev wp plugin activate wordpress-cache-protection

What it does

Hooks at plugin load and runs before WordPress queries posts.

Two modes for handling cache-busting query params:

  • Redirect — 301 → clean URL. Varnish caches the 301, so subsequent dirty hits cost no PHP. Used for params that on-site JS doesn't read from window.location (default: srsltid, fbclid).
  • Strip — internal rewrite of $_GET / REQUEST_URI. Browser URL stays dirty so client-side analytics/ads scripts can still read attribution from window.location; the application sees clean. Used for default: gclid, msclkid, _kx, gbraid, gad_source, gad_campaignid, utm_*, hsa_*, _hsmi, _hsenc, __hstc, __hssc, __hsfp.

Also strips Pantheon's *=PANTHEON_STRIPPED leftovers.

Augments robots.txt with bot-throttling rules for known abuse patterns.

Search protection

Per-IP rate-limit + page-cache kill on search responses. Every search query is unique, so the page cache can never help; meanwhile bots blast random queries to fragment cache and stress the DB.

  • Two flood windows: burst (default 5/10s) + sustained (default 30/60s). Either limit triggers 429.
  • Cache-Control: private, no-store on search responses so Varnish never caches them.
  • Empty ?s= (bare search form) doesn't trigger — stays cacheable.
  • Default search param: s (WP core). Configurable.

Enabled by default; toggle off in Settings → Cache Protection.

Configuration

Settings → Cache Protection in the WP admin. Two textareas for redirect and strip lists, one param per line. Trailing * for prefix wildcards (e.g. utm_*). Search protection has its own section with the windows/thresholds.

Testing

ddev exec bash -c 'cd wp-content/plugins/wordpress-cache-protection && composer install && vendor/bin/phpunit'

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-05-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固