-
Notifications
You must be signed in to change notification settings - Fork 381
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
Use Cache-Control directive for external stylesheet caching #4404
Use Cache-Control directive for external stylesheet caching #4404
Conversation
@schlessera I'm getting warnings still, but different than before:
I can reproduce this each time after I |
I'll add a regression test and fix it. |
Good point. Since $headers = is_object( $response['headers'] ) ? iterator_to_array( $response['headers'] ) : (array) $response['headers']; Anyway, I'll leave you to it 😄 |
The correct interface to check would be https://www.php.net/manual/en/class.traversable.php |
…ove-external-stylesheet-caching * 'develop' of github.com:ampproject/amp-wp: Use static variable for computed constant string Improve phpdoc for Fonts Use AssertContainsCompatibility Ensure color emoji are used for warning symbol Add test for amp-inline-gallery with thumbnails Add test for amp-nested-menu with amp-list Revert "Add (failing) tests for amp-mega-menu reference points" Add (failing) tests for amp-mega-menu reference points Add tests for non-reference point amp-mega-menu markup Add test for amp-subscriptions and note what is lacking Add test for form validation and amp-next-page Add test for amp-story-page[next-page-no-ad], input[type=button], and LTS AMP runtime Add tests for amp-script, amp-next-page, amp-date-picker, and amp-redbull-player Add tests for amp-nested-menu, amp-mega-menu, amp-autocomplete, dock on amp-brid-player, link protocol/type Add test for amp-inline-gallery Remove test for obsolete component amp-user-location Ensure unique GetMandatoryOf parsed from spec Update allowed tags/attributes from spec in amphtml 2003031842100
Build for testing: amp.zip (v1.5.0-alpha-20200318T200637Z-f7034c1c7) |
…thub.com/ampproject/amp-wp into 4293-improve-external-stylesheet-caching
Co-Authored-By: Weston Ruter <westonruter@google.com>
Testing looks good Hi @westonruter and @schlessera,
Here's a snippet I used to test this: add_action(
'wp_enqueue_scripts',
static function() {
wp_enqueue_style( 'example-valid-external-style', 'https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/0.6.0/modern-normalize.min.css' );
wp_enqueue_style( 'non-existent-external-style', 'https://example.com/non-existent.css' );
}
); Sorry for the delay on this. |
Summary
Fixes #2092
This PR does the following:
CachedRemoteGetRequest
andCachedData
into a subnamespaceAmpProject\AmpWP\RemoteRequest
WpHttpRemoteGetRequest
implementation using the WordPressWP_Http
abstraction to implementRemoteGetRequest
CachedRemoteGetRequest
implementation more robustWpHttpRemoteGetRequest
for remote requests in the optimizerWpHttpRemoteGetRequest
to fetch and cache external stylesheetsThe
WpHttpRemoteGetRequest
implementation will respect themax-age
directive of theCache-Control
header and will automatically retry failed remote requests for the following status codes:WP_Http::REQUEST_TIMEOUT
(408)WP_Http::LOCKED
(423)WP_Http::TOO_MANY_REQUESTS
(429)WP_Http::INTERNAL_SERVER_ERROR
(500)WP_Http::SERVICE_UNAVAILABLE
(503)WP_Http::GATEWAY_TIMEOUT
(504)Fixes #4293
Checklist