Use Cache-Control directive for external stylesheet caching#4404
Merged
westonruter merged 15 commits intodevelopfrom Mar 21, 2020
Merged
Use Cache-Control directive for external stylesheet caching#4404westonruter merged 15 commits intodevelopfrom
westonruter merged 15 commits intodevelopfrom
Conversation
Member
|
@schlessera I'm getting warnings still, but different than before: I can reproduce this each time after I |
Member
Collaborator
Author
|
I'll add a regression test and fix it. |
Member
Good point. Since $headers = is_object( $response['headers'] ) ? iterator_to_array( $response['headers'] ) : (array) $response['headers'];Anyway, I'll leave you to it 😄 |
Collaborator
Author
|
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
Member
|
Build for testing: amp.zip (v1.5.0-alpha-20200318T200637Z-f7034c1c7) |
…thub.com/ampproject/amp-wp into 4293-improve-external-stylesheet-caching
westonruter
reviewed
Mar 19, 2020
westonruter
reviewed
Mar 19, 2020
westonruter
reviewed
Mar 20, 2020
Co-Authored-By: Weston Ruter <westonruter@google.com>
westonruter
approved these changes
Mar 20, 2020
Contributor
|
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. |
westonruter
reviewed
Mar 21, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fixes #2092
This PR does the following:
CachedRemoteGetRequestandCachedDatainto a subnamespaceAmpProject\AmpWP\RemoteRequestWpHttpRemoteGetRequestimplementation using the WordPressWP_Httpabstraction to implementRemoteGetRequestCachedRemoteGetRequestimplementation more robustWpHttpRemoteGetRequestfor remote requests in the optimizerWpHttpRemoteGetRequestto fetch and cache external stylesheetsThe
WpHttpRemoteGetRequestimplementation will respect themax-agedirective of theCache-Controlheader 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