ezsystems/ezjscore — pull request #18 by johanberonius (2012-03-28 16:18:19+00:00)
Title: Content returned from a server function that requests not to be cached.

I'd like to use this pull request to discuss the code on line 304 of ezjscpacker.

I understand that some js server functions can request not to be cached by returning -1 from getCacheTime. They do this because they add other files instead and therefore they do not return any content other than the empty string.
But if they were to return any content, since it's added to $data['locale'] array, it's treated as the filename of a local file to be included in the generated cache file. If it's not a valid filename that will cause a PHP warning "file_get_contents: failed to open stream: No such file or directory"

If any returned content is added to the $data['http'] array instead, it's then treated as an URL to an external javascript resource or as a fragment of javascript code to be included inline in its own script-tag. It is possible to add external URLs to the file array today, but it is not possible to insert any javascript code beside the cache file and external URLs.

I've come around this problem since I need to prevent some javascript fragments from being included in the cache file. Almost every page on our site requires a few fragments of unique javascript code and that is causing ezjscpacker to generate a unique cache file for every page on the entire site.