From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1683917058; bh=0l295skEz+VVmXB9BXgVPWHoNrbFmtICsGCtGTVBkrw=; h=From:To:Cc:Subject:Date; b=Z6SkXmHWUBr8dd6ojeIvDOUGYjYCkpWD3tll0f64r/CCGUrX8NLXDcbumAya1H0G8 zrL2A2EqxNJ2CWBicqcvO7i6i7Dpkx9kimaNqlLyDDehEh8TxRvCISvGmeX5ihmYIJ XiOoPSSDvbeMXVVmqPO0jRFKaA64BeXKtV64YgRtBsaG7m0Upqm4X0gH0GPeLNxgUY BvDLrQcUFYiccOI5l5Jl9WR8W2VHe8Y8dTSkpxjrfCvowO9xH3prMpYWquaPQgw+p/ kwzf0n/+qntmoLAPGTohSrp4eL8LFMDZYbXPc2ICOllgqRc3M40jIm5ZWEvElYW2zp fXqOSsb3ZTSiA== Received: from integral2.. (unknown [128.199.192.202]) by gnuweeb.org (Postfix) with ESMTPSA id 45F6F245D38; Sat, 13 May 2023 01:44:16 +0700 (WIB) From: Ammar Faizi To: Ammar Faizi Cc: Michael William Jonathan , GNU/Weeb FB Team , GNU/Weeb Mailing List Subject: [PATCH fb v1 0/3] Facebook Onion assets optimization Date: Sat, 13 May 2023 01:44:08 +0700 Message-Id: <20230512184411.26860-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 --- 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