PHP:通過代理加載圖像的最快方式 (PHP : Fastest way to load images through a proxy)


問題描述

PHP:通過代理加載圖像的最快方式 (PHP : Fastest way to load images through a proxy)

I'm loading some image from a source that is not SSL. In order for this not to break my SSL certificate I have having to load them through this simple PHP proxy page:

<?php
header('Content‑Type: image/png');
if(isset($_GET['url'])){echo file_get_contents($_GET['url']);}
?>

This works but unfortunately I'm experiencing quite slow load times. Does anyone know a faster way to proxy images?

Thanks Guys!

‑‑‑‑‑

參考解法

方法 1:

You could look at X‑Sendfile, it would work a bit like this:

 $file = '/path/to/images/' . $_GET['url'];
 header('X‑Sendfile: ' . $file);

but Apache would be handling the process itself rather than the overhead of PHP.

http://codeutopia.net/blog/2009/03/06/sending‑files‑better‑apache‑mod_xsendfile‑and‑php/

http://www.jasny.net/articles/how‑i‑php‑x‑sendfile/

(by wilsonpageADW)

參考文件

  1. PHP : Fastest way to load images through a proxy (CC BY‑SA 3.0/4.0)

#performance #PHP #SSL #proxy






相關問題

為什麼 Document.html() 這麼慢? (Why is Document.html() so slow?)

Sql中的WHERE,結合兩個快速條件會成倍增加成本 (WHERE in Sql, combining two fast conditions multiplies costs many times)

Tối ưu hóa truy vấn MySQL PHP - Phản hồi (MySQL PHP Query Optimization - Feedbacks)

jGRASP 上的編譯時間很慢——為什麼? (Slow compile times on jGRASP -- why?)

Pandas - 將直方圖桶分配給每一行 (Pandas - assign histogram bucket to each row)

VB.NET 中 Dictionary(Of String, SomeReferenceType) 的性能 (Performance of Dictionary(Of String, SomeReferenceType) in VB.NET)

發送到 Web 客戶端需要多少 JSON? (How much is too much JSON to send over to a web client?)

過期/緩存控制標頭的問題 (Problem with Expires/Cache-Control Headers)

iOS UI 性能分析 (iOS UI performance profiling)

限制內存機器性能的技巧?IIS 應用程序 (Tips for limit memory machine performance? IIS application)

監控 Rails 中站點性能的最佳方法是什麼 (What is the best approach to monitor site performance in rails)

決定 HTTP 標頭的字符集。我應該簡單地把 utf-8 和 fuggedaboutit 放在一起嗎? (Deciding charset for HTTP Headers. Should i simply put utf-8 and fuggedaboutit?)







留言討論