Thanks for contributing a very useful library to the CodeIgniter project. I know this thread is a little old, but I stumbled on it while looking for something else and I think it will be very useful to me.
I have a few questions for you though. I’ve had great success using MD5 for caching assets in my project, but they’re all images… nothing for CSS/JS yet. I’ve always resorted to md5()‘ing the contents of the file, that way only changes to the actual contents cause the cache to invalidate. In the case of Carabiner, might that solve the problem of not functioning in a load balanced setup? I assume the issue with a load balancing is that the modified dates of the files differ across servers, so the filenames differ as well.
Secondly, does Carabiner have to recreate the hash each time? This is somewhat related to the first question… my image assets are actually renamed as md5(file_get_contents(’/path/to/image.jpg’)), and then I store a reference to the image in the database so that I don’t have to md5() the contents ever again. For the purposes of CSS / JS, since you actually want to retain the originals as their original filenames, it seems that you’d need to calculate the hashed filename on every request. If that’s the case, hashing the contents seems like too much overhead.
For a layperson like myself, can you provide a very high level overview of what happens when using Carabiner on the first request as well as subsequent requests? Or maybe you can just confirm my assumptions below?
On each request, Carabiner takes all of the assets that have been passed to it, determines a cached filename for the group of files, and checks to see if that file exists in the cache directory.
If the file does not exist, Carabiner combines the contents of all the files, minifies the contents, and writes it to the filename that it initially checked.
If the file does exist, no combining or minifying is necessary, Carabiner’s work is done.
If these assumptions are true… how would my view obtain the cached filename? It seems also that Carabiner would have to do a few stat system calls on every request. I know these are cached, but can you speak to the efficiency of doing this? I’m ultra performance minded.
I’d like to incorporate Carabiner into a current project, but I really want to understand it before making a decision. Based on the grammatical clarity of your posts, I already expect the library to be of good quality. One can usually make some assumptions of code quality based on the writer’s written language quality.
I really appreciate your efforts and any answers you might provide.