Active
Project:
Speedy
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
10 Apr 2012 at 11:43 UTC
Updated:
11 Apr 2012 at 13:53 UTC
Jump to comment: Most recent file
When the minification process is running it should check the modified date of the source file against the modified date of the minified file. This will improve the performance of the minifcation process- particularly for people who are using a third party remote service. This means that we need to track modification times in speedy_min_js_files. This will require refactoring speedy_js_alter().
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | speedy.diff | 12.84 KB | arthurf |
Comments
Comment #1
arthurf commentedHere's a stab at the drush function to base minification on modification dates. Note that there are a few tweaks here:
* I created a hacked version of file_scan_directory (speedy_file_scan_directory()) which includes a date stamp with the returned $file. Core's file_scan_directory has a callback function option but only passes the $uri to it rather than the $file object so you can't actually modify the $file that is being returned.
* I've tried to abstract this code a bit so it's easier to duplicate- or even just extend
* I haven't tested this code yet. Just working on a proof of concept here
Comment #2
arthurf commentedFirst sorry for this ridiculous patch. It's got changes all over the place. Basically this was a "add modification dates" patch and then suddenly snowballed. I've moved all the core functionality into speedy_minify() This allows you to call this function with your own callback to implement minification. I don't like this so much but it allows the module to handle all the file finding, blacklisting, date checking, etc. Personally I think this is preferable to having developers implement their own mechanisms for doing this. Anyway, I'm happy to discuss some of the changes or untangle things, it just happens to be what is working in my dev environment right now.
Comment #3
mfer commentedThis is an interesting idea. Though, I wonder if time is poor to use and a hash of the file should be used instead. I've seen issues where date stamps get messed up. A hash would detect a change though I realize it adds computational complexity. Thoughts?
Comment #4
arthurf commentedSeems like we could just store an md5 hash of the file rather than the modified date. In speedy_file_scan_directory() we could replace the modified date code with $files[$key]->md5 = md5_file($files[$key]->uri) and in speedy_minify() replace
elseif ($current_minified_files[$file->drupal_filepath]->modified > $file->modified)with
elseif ($current_minified_files[$file->drupal_filepath]->md5 == md5_file($current_minified_files[$file->drupal_filepath]->uri))That work for you?
Comment #5
mfer commentedI'm not sure. Here's why. Every time call md5_file it makes a filesystem call to generate the hash. I would like to not increate the numer of file system calls. While they may be fast, Drupal already does too many of them. I'm not entirely sure here.
Comment #6
arthurf commentedTrue, but these would only be done on calls to speedy_minify() during generation- which is also likely to be called from drush- not ideal I agree with you. Is that a reasonable performance compromise?