Use php's readfile() or redirect to display a image file?

后端 未结 3 998
孤独总比滥情好
孤独总比滥情好 2021-01-21 16:59

I\'ve a directory outside the webroot with images, css and javascripts.
These files often change.
I could write a script which locates the file, figures out the mime

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-21 17:53

    First rule of performance: benchmark, don't speculate.

    I'll promptly break that first rule and speculate that the readfile will be faster, because it eliminates a network round-trip.

    How much performance do you need? The very fastest way to do this would be to setup a separate static-content web server under a subdomain (e.g. http://static.mysite.com/foo.jpg ) on a completely different machine, and then let that web server there handle the often-changing image/css/javascript files.

提交回复
热议问题