Created
January 7, 2018 01:44
-
-
Save davidgilbertson/132497d7e0a9a815b150e35d44660893 to your computer and use it in GitHub Desktop.
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
const linkEl = document.createElement('link'); | |
linkEl.rel = 'prefetch'; | |
linkEl.href = urlWithYourPreciousData; | |
document.head.appendChild(linkEl); |
@davidgilbertson If I am not mistaken, a prefetched resource will be stored in the browser's cache for later reference. Can you give an example of how to run such a cached resource / script?
Here's a link to a w3c issue that got raised a day after this hackernoon article was published. The issue is resolved in another one. In summary, there's a prefetch-src
directive that defaults to default-src
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DNS prefetching can be switched off with the
X-DNS-Prefetch-Control:off
header. For resource prefetching I did not find a similar concept.Some headlines of CSP docs:
So from my point of view if CSP was invented among others for controlling what injected code through XSS attacks, malicious npm dependencies or whatever can send off, I really think we shouldn't be able to bypass it in four lines of code...