docs.rs icon indicating copy to clipboard operation
docs.rs copied to clipboard

Image camo

Open notriddle opened this issue 9 years ago • 5 comments

When an image is included in a README or a doc file, docs.rs links directly to it. It should do like GitHub does and do proxying and caching for it.

notriddle avatar Oct 14 '16 20:10 notriddle

It might make sense to do a "quick" grep across all image tags currently rendered to look for some common domains. If the image is on imgur.com, it's already on a CDN. If it's a github link, it might be possible to rewrite the link to https://rawgit.com instead.

killercup avatar Dec 26 '16 20:12 killercup

This feels a little out of scope. From my understanding, the request is that given a link to an image hosted on an arbitrary domain, docs.rs should download a copy of that image and host it itself so that it doesn't break/is served from the same CDN as the rest of the content.

  1. I'm not sure what benefit this has. Most of big image hosting services will have much better CDNs than we do.
  2. It expands the scope of docs.rs enormously. Currently we host
  • pages rendered by rustdoc
  • pages generated by build.rs
  • nothing else

After this change we'd also store

  • every image any generated page links to

which means that you could potentially overload the server just by publishing a list of the million most popular images.

With that in mind, I don't think this is worth implementing.

jyn514 avatar Jun 28 '20 00:06 jyn514

I think this is something that we should eventually do, as it improves the privacy of users visiting docs.rs. But it's pretty low priority.

pietroalbini avatar Jun 29 '20 12:06 pietroalbini

We don’t need to store images long-term. If we are just proxying and can integrate well with a CDN to do the caching for us then this seems feasible.

Nemo157 avatar Jun 29 '20 13:06 Nemo157

From what I see this would involve rewriting the image-tags in the HTML, or hooking into rustdoc in how it generates the tags.

Both would be (I think) subject to a edge case where custom JS could still generate image links that point somewhere else, which we could solve with using img-src CSP.

The proxy itself could probably be a simple proxy endpoint. Caching it would be tricky, since I assume these external images are often dynamically generated, and used to inject dynamic content into the static docs.

The privacy improvement is IMO a valid reason to work on this.

syphar avatar Oct 24 '23 07:10 syphar