Closed (fixed)
Project:
CDN
Version:
6.x-2.0-rc4
Component:
Module
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
28 Oct 2010 at 20:12 UTC
Updated:
13 Nov 2010 at 13:10 UTC
Thanks for this great module Wim. Even newbs like me are able to install and configured this module properly.
I need some help being able to use the cdn_pick_server() function, so that Drupal use our different CDN's for all the .js, .css and images, being able to parallelize downloads across different CDNs.
I've read the README and used the following code at PHP code for cdn_pick_server():
/**
* Implementation of cdn_pick_server().
*/
function cdn_pick_server($servers_for_file) {
$filename = basename($servers_for_file[0]['url']);
$unique_file_id = hexdec(substr(md5($filename), 0, 5));
return $servers_for_file[$unique_file_id % count($servers_for_file)];
}
Inside the PHP code for cdn_pick_server(): block without success. Just in case, at the CDN mapping block, I've placed 2 URL's:
http://cdn.mydomain.com
http://cdn2.mydomain.com
Yet, all our content is being delivered by the first CDN.
Any idea or help will be greatly appreciated!
Comments
Comment #1
wim leersI bet you used the form at admin/settings/cdn/other? I.e. you didn't create a new small module for this?
Then there are two reasons:
1) You didn't copy the body of the function, but the whole function. This is wrong. I've improved the README.txt about this:
2) The eval'd PHP code version of cdn_pick_server() was not actually being called yet! Oops! Fixed that too!
Fix committed: http://drupal.org/cvs?commit=443636
Comment #2
Duplika commentedTerrific Wim! After installing the new release, everything seems to be working fine great!
In my case, most of the images are loaded from the CSS so I don't quite benefit from parallelization. This has nothing to do with your module, but to accomplish this, should I modify the CSS so that some images are being called from one cdn and others, from the other?
Is that the recommended approach?
Comment #3
wim leersWhat you're suggesting would work, but it would also mean that you would have to edit the CSS files manually.
There's two alternatives to that:
1) Use File Conveyor, but you'll have to write a custom file processor in Python to automatically balance image files from different CDNs. This of course means that you'll have to install File Conveyor, which is a non-trivial task.
2) Use the Support File Cache module, which can generate smarter CSS bundles (well, not generate, it allows *you* to define these bundles). This effectively means that you've got more CSS files, and thus that the images will automatically be balanced over as many CDNs as you have CSS files (bundles).