-
Notifications
You must be signed in to change notification settings - Fork 110
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
Prevent speculatively loading links to the uploads, content, plugins, template, or stylesheet directories #1167
Prevent speculatively loading links to the uploads, content, plugins, template, or stylesheet directories #1167
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@westonruter Would it make sense to instead prevent speculative loading of any links to something within |
@felixarntz yeah, good point. That should be added as another entry specific to |
For completeness, the following URLs should be excluded: |
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.
Nice work!
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.
LGTM
Build for testing: speculation-rules.zip |
This was brought up by @AntonyXSI in #1157:
See Chrome's behavior for speculative loading of an image and a PDF: #1157 (comment).
In this PR, the uploads directory is excluded from speculative loading. The uploads directory path is added to the base href excludes.
What if the uploads directory is pointing to a CDN instead? Well, it will be ignored anyway because the speculation rules are configured to only do same-origin speculative loads:
performance/plugins/speculation-rules/helper.php
Lines 83 to 91 in cb5a37e
So they will be excluded anyway. (The same goes for a site with a site customizing the
site_url
to point to another domain, cf. #1164). But what if someone wants to do cross-origin speculative loads? That could be made possible with #1156 where thehref_matches
is changed from/*
to instead be*://*/*
. Nevertheless, it seems Chrome does not currently support this:Nevertheless, the above was specifically for prerendering. If I try instead with the mode set to prefetch, I get different results:
So it can work with prefetch in some situations.
We should keep that in mind for the future.