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);
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.