Throttle and optimize `/wp-json/optml/v1/optimizations` REST API endpoint execution and validation

未关闭
#1,250 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃

调研方向

Start by locating the registration of the /wp-json/optml/v1/optimizations REST route and the client script that POSTs the optimization reports. Read the callback for the route to see which mandatory fields are consumed and where heavy profiling or database writes begin, then check the client dispatch path to find where debounce/rate-limit logic belongs. Done means the client sends at most one throttled report per page session and invalid payloads return 400 before any heavy service is initialized; no linked tests or files are named in the issue, so confirm the expected behaviour with a maintainer first.

由索引模型根据 Issue 内容生成。

描述

customer report feature-request-triage

Impact: 80 · Confidence: 90 · Complexity: 50

Description

Problem

The Optimole frontend script triggers high volumes of POST requests to /wp-json/optml/v1/optimizations (e.g., 500+ requests over 6 hours), with a high percentage (~21%) failing with HTTP 400 Bad Request while still instantiating full WordPress PHP processes and consuming substantial CPU time (e.g. 391 seconds across 525 requests).

Desired Behavior

Optimole should debounce/throttle client-side optimization report payloads, restrict redundant API dispatches, and perform lightweight request validation early in REST API execution to return HTTP 400 responses with minimal PHP processing overhead.

Acceptance Criteria
  • Client-side script debounces and rate-limits POST dispatches to /wp-json/optml/v1/optimizations per page session.
  • Server-side REST endpoint performs early validation of mandatory fields before executing heavy profiling logic or database writes.
  • High-frequency invalid payloads (HTTP 400) exit early without executing unnecessary internal routines.

Customer Context

A paid subscriber reported server resource exhaustion (391s of PHP processing time across 525 requests in 6 hours; 4,969 requests over 3 days) driven by /wp-json/optml/v1/optimizations, with over 20% returning HTTP 400 bad request errors.

Root Cause Analysis

The customer experiences high PHP usage due to continuous background REST calls to /wp-json/optml/v1/optimizations and wants a way to rate-limit or protect the endpoint. The underlying problem is unthrottled client-side profiler beacons combined with heavyweight processing on invalid payload requests (HTTP 400). Rather than expecting customers to add external rate-limiting rules, Optimole should improve its own beacon frequency, client-side debouncing, and server-side early rejection routines.

Alternative Suggestions

Debounce page profiling network requests on the client side, implement client-side check to skip sending empty/invalid optimization payloads, and add early parameter schema validation on /wp-json/optml/v1/optimizations before initializing heavy services.


Source: HelpScout #3524196151
Generated by feature-request-triage workflow (ID: feature-request-triage_6b0599ff05a6a1.02374250)

主要语言
PHP
星标
74
派生
14
平均合并
1 天 2 小时
30 天内合并 PR
35

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Codeinwp/optimole-wp 的其他 Issue

查看 Codeinwp/optimole-wp 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。