Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I would like to distribute the aggregated bundles among several "cookie less" subdomains that I've set up.
I've created a module that lets me specify the available subdomains.
During hook_advagg_filenames_alter one of the subdomains is chosen at random and inserted into the array passed to the hook implementation. However, this information cannot be passed on to do anything meaningful.
Is there a better place to insert such information?
Also, I'd like to use this during advagg_build_css/js_bundle(). This would require to have different files for http and https.
Any suggestions?
Comment | File | Size | Author |
---|---|---|---|
#3 | advagg-1273250-3.patch | 1.16 KB | mikeytown2 |
#2 | bundler.patch | 307 bytes | killes@www.drop.org |
#2 | advagg_subdomains.module.txt | 2.05 KB | killes@www.drop.org |
Comments
Comment #1
mikeytown2 CreditAttribution: mikeytown2 commentedI've built advagg with the assumption that the CDN module would be used for things like this. The schema and host get set in advagg_build_uri.
advagg_build_css/js_bundle are fairly simple functions. If you wish to modify what goes in here I would use hook_advagg_css_pre_alter() & hook_advagg_js_pre_alter(). If the cache is getting in the way then disable it:
hook_advagg_disable_processor() is the only hook that runs every time; disable the cache in here. You can see an example of this hook in action here #1246816: Create workaround for jquery update ahah form bug when using node clone and a filefield loading jquery.js from googles cdn.
Comment #2
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedThanks for your comment.
I think we are thinking of different things here.
I've developed the module I was talking about, please see the attached file.
Initially, I wanted to use the filename_alter hook, but this proved to be difficult since the bundle information isn't passed on.
Now I am using hook_advagg_css/js_alter and store the information similar to how the compress_js module does it.
This approach relies on two things:
1) a one-line patch to advagg to use file_create_url().
2) Pressflow, or the patch that comes with the CDN module.
It is slighly inelegant since I have to parse the bundler md5 out of the filename in the file_url_alter hook...
Comment #3
mikeytown2 CreditAttribution: mikeytown2 commentedI would do a advagg_get_file_data(), merge in your data, and then call advagg_set_file_data().
Here's a patch for advagg that I have for you to test out. I would like to keep the default behavior that is found in drupal_get_css if the hook_file_url_alter patch hasn't been applied.
Comment #4
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedThanks, your approach looks more stable.
The patch to advagg seems to break something, the css files get created but have size 0.
Comment #5
mikeytown2 CreditAttribution: mikeytown2 commentedhmmm I can't repo that on my test box with the patch. See if your subdomains module is causing issues.
Comment #6
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedI think it's not the module as such, but some issue with the cdn patch. Did you try with or without?
Comment #7
mikeytown2 CreditAttribution: mikeytown2 commentedWith the CDN patch.
Comment #8
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedStrange. I'll debug more tomorrow.
Comment #9
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedIt seems as if my subdomain data is ending up in file_save_file() which of course doesn't like an array as input.
Comment #10
mikeytown2 CreditAttribution: mikeytown2 commentedyep! That is the error.
I gotta think of better variable names besides data
Comment #11
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedheh, I had even seen that and removed the &. Of course php5 foiled that...
Everything seems to work now, thanks again!
Comment #12
mikeytown2 CreditAttribution: mikeytown2 commentedComment #13
mikeytown2 CreditAttribution: mikeytown2 commentedcommitted
Comment #14
mikeytown2 CreditAttribution: mikeytown2 commentedNice module :)
http://drupal.org/project/cookieless_subdomain
I'll try to get a stable release out the door sooner rather then later for ya.