开发者

PHP : Fastest way to load images through a proxy

开发者 https://www.devze.com 2023-03-17 03:41 出处:网络
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 P开发者_StackOverflow中文版HP proxy page:

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 P开发者_StackOverflow中文版HP 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!


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消