問題描述
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 wilsonpage、ADW)