Skip to content

Blocking assets: treat non-cacheable and zero-size responses as error…#2418

Open
tejas0306 wants to merge 1 commit intoWordPress:trunkfrom
tejas0306:fix/blocking-assets-non-cacheable-and-zero-size
Open

Blocking assets: treat non-cacheable and zero-size responses as error…#2418
tejas0306 wants to merge 1 commit intoWordPress:trunkfrom
tejas0306:fix/blocking-assets-non-cacheable-and-zero-size

Conversation

@tejas0306
Copy link

Summary

Fixes #2417

This PR improves error handling for invalid and non-cacheable HTTP responses.

Changes

  • Return WP_Error when response body is empty (0 bytes)
  • Return WP_Error when Cache-Control contains no-store or no-cache
  • Add tests for:
    • zero_size response
    • non_cacheable response

Technical Notes

  • Added validation checks before processing response
  • Scoped changes strictly to error handling
  • Maintains backward compatibility

fixes WordPress#2417)

- Return WP_Error for empty response body (0 bytes)
- Return WP_Error when Cache-Control contains no-store or no-cache
- Add tests for zero_size and non_cacheable cases

Fixes WordPress#2417
@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: tejas0306 <suhan2411@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.40%. Comparing base (9bd9d23) to head (61f27fe).

Additional details and impacted files
@@            Coverage Diff             @@
##            trunk    #2418      +/-   ##
==========================================
+ Coverage   69.33%   69.40%   +0.06%     
==========================================
  Files          90       90              
  Lines        7749     7765      +16     
==========================================
+ Hits         5373     5389      +16     
  Misses       2376     2376              
Flag Coverage Δ
multisite 69.40% <100.00%> (+0.06%) ⬆️
single 35.66% <0.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@b1ink0 b1ink0 added [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Type] Enhancement A suggestion for improvement of an existing feature labels Mar 17, 2026
@b1ink0 b1ink0 added this to the performance-lab n.e.x.t milestone Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enqueued Assets audit: treat non-cacheable and zero-size responses as errors

2 participants