Q:

Serving .APK file from CDN with headers to install in Android

I want to serve a .APK file to users to download. I have a CDN and it works fine. When I request file download, It downloads from CDN. But I have a problem. My users request downloads from Android devices, in this case, Downloading pure APK file goes trouble because I want to users install that APK file and with pure APK it's not possible as I know. So I create a .php file like this and add 'Content-Type: application/vnd.android.package-archive':
<?php

$file = 'myfile.apk'; //File that we want to send to user.

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/vnd.android.package-archive');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
?>

When I request download.php, Its work and users can download and install the APK file. And now my question is, In this case, That file downloads from the CDN? I want both download.php and APK file served from CDN because I don't have enough traffic. 
Or is this possible to add 'Content-Type: application/vnd.android.package-archive' to downloading file from CDN without php?
PS: When i request pure APK file, Because it's from CDN, It downloads instantly like it's caching, But with download.php, It takes time to download. it means in this case it's not from CDN?

A:

Or is this possible to add 'Content-Type: application/vnd.android.package-archive' to downloading file from CDN without php?

Yes, downloading must work correct in this case.

But with download.php, It takes time to download. it means in this case it's not from CDN?

It takes time, because you use readfile and output buffering. In this case, download started only after php fully load content of target file into memory. This is potential problem, if you plan serve big apk files.
You can serve them, to example in this way:
// set headers here ...
$output = fopen('php://out', 'a');
$target = fopen($target, 'r');

if (!$target || !$output) {
    //  throw error, if cant read file or 
}

// read target file, using buffer size 1024
while (!feof($target)) {
    fwrite($output, fread($target, 1024), 1024);
}

fclose($target);
fclose($output);

