-
Notifications
You must be signed in to change notification settings - Fork 128
Prevent effective asset cache headers audit from running on local/development environments #2035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
490d093
48271bf
284b7f3
85573d7
d6565a0
5413da2
f56f9d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…nment
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,16 @@ function perflab_effective_asset_cache_headers_add_test( array $tests ): array { | |
'label' => __( 'Effective Caching Headers', 'performance-lab' ), | ||
'test' => 'perflab_effective_asset_cache_headers_assets_test', | ||
); | ||
|
||
/** | ||
* Static assets are expected to not have effective cache headers in non-production environments. | ||
* | ||
* GH Issue: https://github.com/WordPress/performance/issues/2031 | ||
*/ | ||
if ( in_array( wp_get_environment_type(), array( 'local', 'development' ), true ) ) { | ||
unset( $tests['direct']['effective_asset_cache_headers'] ); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of unsetting something that was set, why not just short-circuit the function to avoid setting it in the first place, or rather wrap the setting with the if ( ! in_array( wp_get_environment_type(), array( 'local', 'development' ), true ) ) {
$tests['direct']['effective_asset_cache_headers'] = array(
'label' => __( 'Effective Caching Headers', 'performance-lab' ),
'test' => 'perflab_effective_asset_cache_headers_assets_test',
);
}
return $tests; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it can be work and even more instead of wrapping it in /*
* Bail early.
*/
if ( in_array( wp_get_environment_type(), array( 'local', 'development' ), true ) ) {
return $tests;
}
$tests['direct']['effective_asset_cache_headers'] = array(
'label' => __( 'Effective Caching Headers', 'performance-lab' ),
'test' => 'perflab_effective_asset_cache_headers_assets_test',
);
return $tests; |
||
|
||
return $tests; | ||
} | ||
add_filter( 'site_status_tests', 'perflab_effective_asset_cache_headers_add_test' ); | ||
add_filter( 'site_status_tests', 'perflab_effective_asset_cache_headers_add_test', 100 ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the change to priority 100? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to make sure it would run after all the filters, I thought it would be filter somewhere else as well, but priority 100 can be removed though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.