/[drupal]/contributions/modules/cdn/README.txt
ViewVC logotype

Contents of /contributions/modules/cdn/README.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.14 - (hide annotations) (download)
Mon Jan 21 21:45:31 2008 UTC (22 months ago) by wimleers
Branch: MAIN
Changes since 1.13: +4 -1 lines
File MIME type: text/plain
- Abstracted the cdn_file() function to an "URL rewrite function" for core usage. This will allow you to have any number of backends to serve files from. Updated the core patches, the documentation and the code accordingly.
1 wimleers 1.14 // $Id: README.txt,v 1.13 2008/01/14 00:40:08 wimleers Exp $
2 wimleers 1.6
3     Description
4     -----------
5     The aim of this module to provide easy Content Delivery Network integration
6     for Drupal sites. Obviously it has to patch Drupal core to rewrite the URLs,
7     not only to serve them from another domain, but also to make the filenames
8     unique.
9    
10     It has synchronization plugins, so it allows you to use any protocol or
11     algorithm to synchronize your files. Currently however, only one plugin is
12     available: FTP. Since proper usage of a CDN demands unique filenames for each
13     version of a file, we can optimize a lot: to validate a file on the CDN while
14     synchronizing, we must only know if it 1) exists and 2) has the correct size.
15    
16     Which files and directories should be synchronized can be configured very
17     precisely. Consult the README for details about that.
18    
19     The FTP synchronization plugin allows you to use a $15 per month CDN (thus
20 wimleers 1.9 making CDNs accessible to /a lot/ of Drupal users) with no effort after the
21 wimleers 1.6 installation!
22     For those who know of the infamous YSlow test: if you install and configure
23     this module and apply the core patch that also adds Javascript aggregation,
24     you will score 98. Almost the maximum! The remainder of points is due to the
25     lack Javascript minification (compression).
26    
27     This module was developed for http://driverpacks.net/.
28    
29    
30 wimleers 1.7 Aren't CDN's so expensive only big companies can afford them?
31     -------------------------------------------------------------
32     Not anymore (in order of best price-value ratio):
33    
34     1) CacheFly, http://cachefly.com/, starts at USD 15 for 30 GB per month
35    
36     2) Influxis, http://influxis.com/, starts at USD 10 for 1 GB per month
37    
38    
39 wimleers 1.6 Installation
40     ------------
41     1) Place this module in your modules directory (this will usually be
42     "sites/all/modules/").
43    
44     2) Enable the module.
45    
46     3) Apply the Drupal core patch. See below.
47    
48     4) Apply the theme patch to every theme. See below.
49    
50     5) Read how to configure the CDN synchronization filters. See below.
51    
52     6) Configure the $conf array in settings.php See below.
53    
54     7) Copy cdn_cron.php to your Drupal root directory.
55    
56     8) Configure cdn_cron.php like Drupal's cron.php. See http://drupal.org/cron.
57    
58     9) Go to admin/logs/status. If the CDN integration module is installed
59     correctly or not, it will report so here.
60    
61    
62     Usage
63     -----
64     When the module is installed properly (see step 9 of the installation), you
65     can check the site-wide statistics at admin/settings/cdn. At that same page,
66     you can enable the per-page statistics as well. This will show the number of
67     files served from the CDN at the bottom of each page, as well as a list of
68     files that haven't been synchronized to the CDN yet, to users with the
69     "administer site configuration" permission.
70    
71 wimleers 1.1
72     Applying the Drupal core patch
73     ------------------------------
74 wimleers 1.8 You *must* apply this patch! It has been created against Drupal 5.5.
75 wimleers 1.1
76     First, change the directory to the Drupal root directory.
77    
78     You can apply the included Drupal core patch like this:
79     patch -p0 < drupal_core_cdn_integration.patch
80    
81     To undo the patch:
82     patch -p0 -R < drupal_core_cdn_integration.patch
83    
84 wimleers 1.5 Note: there is also a patch that combines the CDN integration core patch with
85     the JS aggregation. It's included in this module because if you apply both
86     patches separately, you will get a conflict.
87    
88 wimleers 1.1
89     Applying the theme patch
90     ------------------------
91     You *must* apply this patch to *every* theme that's being used on your website!
92    
93     Repeat this process for every theme: first, change the directory to the
94     directory of the theme. Applying the patch is identical to the example above,
95     only with a different filename.
96    
97    
98 wimleers 1.6 Setting up CDN synchronization filters
99     --------------------------------------
100     First of all: each filter works *recursively*! Now, the explanations:
101 wimleers 1.2 - paths: This is an array of paths (each path being relative to the Drupal
102     root directory) on which this filter should be applied.
103 wimleers 1.6 - pattern: Regular expression that will be used to filter the files in each
104 wimleers 1.2 directory. Like the $mask parameter in file_scan_directory().
105 wimleers 1.6 - ignored_dirs: Array of directories that should be ignored in each directory.
106     Like the $nomask parameter in file_scan_directory().
107 wimleers 1.2 - unique: Determines how the uniqueness will be applied. You can set it to
108     'filename', which will alter the filename, or 'common parent
109     directory', which will alter the path of the file. The latter is
110     strongly recommended for themes, since it will not break URLs in
111     CSS files.
112     - unique_method: The method that should be used to generate unique filenames.
113 wimleers 1.12 Currently supported: 'none' (no unique filename!), 'mtime'
114     (the file's mtime property), 'md5' (md5 hash of the file) or
115     'md5 of mtimes' (md5 hash of the concatenated mtimes of a set
116     of files). This last option is only available if you have set
117     the unique property to 'common parent directory'.
118 wimleers 1.2
119    
120 wimleers 1.1 Configuring the $conf array in settings.php
121     -------------------------------------------
122 wimleers 1.2 This is my configuration:
123 wimleers 1.1
124     $conf = array(
125 wimleers 1.14 'file_url_rewrite' => array(
126     'cdn_file_url', // List the CDN module's URL rewrite function as the preferred server.
127     ),
128 wimleers 1.2 'cdn_url' => 'http://wimleers.cachefly.com/wimleers.com',
129 wimleers 1.1 'cdn_sync_filters' => array(
130 wimleers 1.6 // Add all Javascript, CSS, image and flash files from the most common
131     // directories in Drupal.
132 wimleers 1.2 0 => array(
133     'paths' => array('misc', 'profiles', 'modules', 'sites/all/modules', 'sites/default/modules'),
134 wimleers 1.12 'pattern' => '.*\.(ico|js|css|gif|png|jpg|jpeg|svg|swf)$',
135 wimleers 1.3 'ignored_dirs' => array('CVS'),
136 wimleers 1.2 'unique' => 'filename',
137     'unique_method' => 'mtime',
138     ),
139 wimleers 1.6
140     // We want to add *everything* in the files directory. Except for the
141 wimleers 1.13 // files in the CSS and JS directory, because they need other treatment:
142     // we assume that files in this directory don't change, so we can use
143     // non-unique filenames, resulting in nicer filenames when they're
144     // downloaded.
145 wimleers 1.2 1 => array(
146     'paths' => array('sites/wimleers.com/files'),
147     'pattern' => '.*',
148 wimleers 1.13 'ignored_dirs' => array('CVS', 'css', 'js'),
149     'unique_method' => 'none',
150     ),
151    
152     // Add all files in the files/css directory, *but* update the URLs in the
153     // files. This is only necessary if we use CSS aggregation.
154     2 => array(
155     'paths' => array('sites/wimleers.com/files/css'),
156     'pattern' => '.*',
157     'ignored_dirs' => array('CVS'),
158     'unique' => 'filename',
159     'unique_method' => 'mtime',
160     'update_urls_in_files' => TRUE,
161     ),
162    
163     // Add all files in the files/js directory. This is only necessary if we
164     // use JS aggregation.
165     3 => array(
166     'paths' => array('sites/wimleers.com/files/js'),
167     'pattern' => '.*',
168     'ignored_dirs' => array('CVS'),
169     'unique' => 'filename',
170     'unique_method' => 'mtime',
171 wimleers 1.2 ),
172 wimleers 1.6
173     // Add all Javascript, CSS, image and font files from our themes. But
174     // make sure the URLs don't break when CSS aggregation is disabled, by
175     // using the "common parent directory" unique level and the "md5 of mtimes"
176     // uniqueness method. We can revert to normal values if we have CSS
177     // aggregation enabled.
178 wimleers 1.13 4 => array(
179 wimleers 1.2 'paths' => array('sites/default/themes/garland-customized'),
180 wimleers 1.10 'pattern' => '.*\.(js|css|gif|png|jpg|jpeg|otf)$', // We *include* css files, because some (e.g. fix-ie.css) are not included in the aggregation.
181 wimleers 1.3 'ignored_dirs' => array('CVS'),
182 wimleers 1.2 'unique' => 'common parent directory',
183     'unique_method' => 'md5 of mtimes',
184     ),
185 wimleers 1.1 ),
186     'cdn_sync_method' => 'ftp',
187     'cdn_sync_method_settings' => array(
188     'host' => 'ftp.cachefly.com',
189 wimleers 1.2 'remote_path' => 'wimleers.com',
190 wimleers 1.1 'port' => 21,
191     'user' => 'user',
192     'pass' => 'pass',
193     ),
194     );
195 wimleers 1.6
196    
197     Author
198     ------
199     Wim Leers
200    
201     * mail: work@wimleers.com
202     * website: http://wimleers.com/work
203    
204     The author can be contacted for paid customizations of this module as well as
205     Drupal consulting, development and installation.

  ViewVC Help
Powered by ViewVC 1.1.2