Sometimes, there may be a need to have PHP variables in externalized css or js files. Due to which, PHP should process it.
It can save http requests and cause the page to load faster.
But, rather than reading and compiling each resource file on the fly,
try to make a single file with all the contents of css within it, and load it.
For example:
c.css = a.css + b+css
When a user requests, static.php?css=a.css,b.css or any other combination, you can still find out a single file (c.css) that has all the contents necessary. It is different to static.php?css=b.css,a.css.
You will first, sort the files by their names. So, the queue of b.css and a.css becomes:
$css = array();
$css[] = 'a.css';
$css[] = 'b.css';
sort($css);
$css_hash = md5(implode('', $css));
Now, send cache the css file, ‘$css_hash.css’ if exists.
This forces to reuse the cache file even if your requested css files are not in same order while you build <link> tag.
By this way, your request to static.php?css=a.css,b.css and static.php?css=b.css,a.css (by mistake, say), will still search for single cache file.
It won’t matter how many cache files you have; a total of css caches may not reach 1 MB!