Hacker News new | ask | show | jobs
by aembleton 807 days ago
> Worse, they even do it if you "open image in new tab".

How does it know where to get the CSS or picture element from to manage that? Maybe it keeps it from the other page. Does this happen in all browsers? I don't think I've seen this in Firefox.

1 comments

It looks at the request headers.

When you navigate to https://i.redd.it/dl34o62azctc1.jpeg, Chrome sends (I'm doing this on Chrome because I think I've made some hacks in Firefox to fix this)

  GET https://i.redd.it/dl34o62azctc1.jpeg
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
and Reddit responds with a redirect to https://www.reddit.com/media?url=https://i.redd.it/dl34o62az....

But when the browser loads the same image from an <img src="..."> tag, Chrome sends

  GET https://i.redd.it/dl34o62azctc1.jpeg
  Accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8
and Reddit responds with the actual image.
Why make a new request? The image is already loaded.