I have a lot of JS and CSS files for my site. In order to minimize connection requests from browsers, I join them in a single php file. I'm using header parameters to force the files to BE cached. Here is how I do for the JS case (CSS is exactly the same way):
<?php
ob_start("ob_gzhandler");
$expires= 60 * 60 * 24 * 14;
header('Pragma: public');
header('Cache-Control: max-age=' . $expires);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
header('Content-type: text/javascript');
include('file1.js'); echo "\n\n\n";
include('file2.js'); echo "\n\n\n";
/* ... bla bla bla bla ... */
include('fileY.js'); echo "\n\n\n";
include('fileZ.js'); echo "\n\n\n";
ob_end_flush();
?>
This works just fine in Firefox. For the rest of the planet those files are not caching! Both of them are quite big, so I have an annoying half second white screen in order the other browsers to load them again and again for each page request.
I suppose this has something to do with header's Content-Length. I try 2-3 things but I couldn't make it work. Any suggestions?
Thank you in advance. Any help is appreciate.