Reputation: 3188
I want to use a PHP script as an intermediary to serve a .JS.GZ file with appropriate response headers and caching headers. How much more CPU intensive is this as compared to just serving the file directly? How could I benchmark the CPU usage?
$file = fopen('autocomplete.js.gz', 'rb');
echo fpassthru($file);
Upvotes: 0
Views: 432
Reputation: 145482
readgzfile()
is the most efficient solution PHP itself has to offer. The inflate decompression algorithm itself doesn't consume much CPU power, and has only a small memory footprint as well (well normally). It's one of the most optimized zlib functions.
Upvotes: 1
Reputation: 41040
readfile('autocomplete.js.gz');
Usage of xsendfile:
<?php
header('X-Sendfile: autocomplete.js.gz'); // does not use any PHP memory!
Upvotes: 1