GNU/Weeb Mailing List <[email protected]>
 help / color / mirror / Atom feed
* [PATCH fb v1 0/3] Facebook Onion assets optimization
@ 2023-05-12 18:44 Ammar Faizi
  2023-05-12 18:44 ` [PATCH fb v1 1/3] fb: web: Don't use proxy if the host isn't an onion domain Ammar Faizi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ammar Faizi @ 2023-05-12 18:44 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: Michael William Jonathan, GNU/Weeb FB Team, GNU/Weeb Mailing List

Hi,

Facebook Onion CDN is slow...

Replace Facebook onion asset endpoint with non-onion for faster response
time. Avoid HTTP request to Facebook onion if possible. When using
Facebook onion, the CDN asset URL looks like this:

  https://scontent.xx.facebookcooa4ldbat4g7iacswl3p2zrf5nuylvnhxn6kqolvojixwid.onion/something

we can simply replace the domain with scontent.xx.fbcdn.net to get the
same asset:

  https://scontent.xx.fbcdn.net/something

Side note: We don't fully understand how Facebook actually manages their
CDN. We may introduce a subtle issue by doing it this way. But we hope
we don't.

There are 3 patches in this series:

1. Don't use proxy if the host isn't an onion domain.

Speed up the HTTP request by not using the Tor proxy if the destination
host is not an onion domain. This is also a preparation to handle
Facebook assets (photos, video, files) better and faster.

2. Introduce `build_url()` function.

Introduce build_url() function to construct a URL based on the return
value of parse_url(). Currently, the only purpose of this function is to
easily change the hostname without inventing our own URL parser. This
function is taken from an answer on the stackoverflow site. I put the
stackoverflow link in the commit message.

3. Replace Facebook onion asset endpoint with non-onion.

We're mucking around with the URL here, in patch #3.

Signed-off-by: Ammar Faizi <[email protected]>
---

The following changes since commit 68e95a61956e75ad08ad0bb68f10172fd2883816:

  Merge branch 'dev.cache' (Facebook scraper cache) (2023-05-09 17:59:03 +0700)

are available in the Git repository at:

  https://gitlab.torproject.org/ammarfaizi2/Facebook.git dev.fast_asset

for you to fetch changes up to 8a74bcd85a0ea781ed23c77527af288abcfff900:

  fb: web: Replace Facebook onion asset endpoint with non-onion (2023-05-13 01:35:01 +0700)

----------------------------------------------------------------
Ammar Faizi (3):
      fb: web: Don't use proxy if the host isn't an onion domain
      fb: helper: Introduce `build_url()` function
      fb: web: Replace Facebook onion asset endpoint with non-onion

 src/Facebook/helpers.php | 18 ++++++++++++++++++
 web/public/api.php       | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)

base-commit: 68e95a61956e75ad08ad0bb68f10172fd2883816
-- 
Ammar Faizi


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-12 19:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-12 18:44 [PATCH fb v1 0/3] Facebook Onion assets optimization Ammar Faizi
2023-05-12 18:44 ` [PATCH fb v1 1/3] fb: web: Don't use proxy if the host isn't an onion domain Ammar Faizi
2023-05-12 18:44 ` [PATCH fb v1 2/3] fb: helper: Introduce `build_url()` function Ammar Faizi
2023-05-12 18:44 ` [PATCH fb v1 3/3] fb: web: Replace Facebook onion asset endpoint with non-onion Ammar Faizi
2023-05-12 19:10 ` [PATCH fb v1 0/3] Facebook Onion assets optimization GNU/Weeb Facebook Team

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox