/[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.17 - (show annotations) (download)
Sun Feb 17 20:19:01 2008 UTC (21 months, 1 week ago) by wimleers
Branch: MAIN
Branch point for: DRUPAL-5
Changes since 1.16: +5 -2 lines
File MIME type: text/plain
Improved docs for applying the theme patch.
1 // $Id: README.txt,v 1.16 2008/01/27 14:21:47 wimleers Exp $
2
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 making CDNs accessible to /a lot/ of Drupal users) with no effort after the
21 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 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 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
72 Applying the Drupal core patch
73 ------------------------------
74 You *must* apply this patch! It has been created against Drupal 5.5.
75
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 < d5_file_url_rewrite.patch
80
81 To undo the patch:
82 patch -p0 -R < d5_file_url_rewrite.patch
83
84 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. This patch also sets the default
87 location for drupal.js and jquery.js to the footer of the page, and defaults
88 calls to drupal_add_js() to the footer as well.
89
90
91 Applying the theme patch
92 ------------------------
93 You *must* apply this patch to *every* theme that's being used on your
94 website! Note that the provided patch only works for Garland. You'll have to
95 apply similar changes (i.e. wrap the URL in a file_url() call) to the themes
96 you're using.
97
98 Repeat this process for every theme: first, change the directory to the
99 directory of the theme. Applying the patch is identical to the example above,
100 only with a different filename.
101
102
103 Setting up CDN synchronization filters
104 --------------------------------------
105 First of all: each filter works *recursively*! Now, the explanations:
106 - paths: This is an array of paths (each path being relative to the Drupal
107 root directory) on which this filter should be applied.
108 - pattern: Regular expression that will be used to filter the files in each
109 directory. Like the $mask parameter in file_scan_directory().
110 - ignored_dirs: Array of directories that should be ignored in each directory.
111 Like the $nomask parameter in file_scan_directory().
112 - unique: Determines how the uniqueness will be applied. You can set it to
113 'filename', which will alter the filename, or 'common parent
114 directory', which will alter the path of the file. The latter is
115 strongly recommended for themes, since it will not break URLs in
116 CSS files.
117 - unique_method: The method that should be used to generate unique filenames.
118 Currently supported: 'none' (no unique filename!), 'mtime'
119 (the file's mtime property), 'md5' (md5 hash of the file) or
120 'md5 of mtimes' (md5 hash of the concatenated mtimes of a set
121 of files). This last option is only available if you have set
122 the unique property to 'common parent directory'.
123
124
125 Configuring the $conf array in settings.php
126 -------------------------------------------
127 This is my configuration:
128
129 $conf = array(
130 // CDN integration module settings.
131 'cdn_url' => 'http://wimleers.cachefly.com/wimleers.com',
132 'cdn_sync_filters' => array(
133 // Add all Javascript, CSS, image and flash files from the most common
134 // directories in Drupal.
135 0 => array(
136 'paths' => array('misc', 'profiles', 'modules', 'sites/all/modules', 'sites/default/modules'),
137 'pattern' => '.*\.(ico|js|css|gif|png|jpg|jpeg|svg|swf)$',
138 'ignored_dirs' => array('CVS'),
139 'unique' => 'filename',
140 'unique_method' => 'mtime',
141 ),
142
143 // We want to add *everything* in the files directory. Except for the
144 // files in the CSS and JS directory, because they need other treatment:
145 // we assume that files in this directory don't change, so we can use
146 // non-unique filenames, resulting in nicer filenames when they're
147 // downloaded.
148 1 => array(
149 'paths' => array('sites/wimleers.com/files'),
150 'pattern' => '.*',
151 'ignored_dirs' => array('CVS', 'css', 'js'),
152 'unique_method' => 'none',
153 ),
154
155 // Add all files in the files/css directory, *but* update the URLs in the
156 // files. This is only necessary if we use CSS aggregation.
157 2 => array(
158 'paths' => array('sites/wimleers.com/files/css'),
159 'pattern' => '.*',
160 'ignored_dirs' => array('CVS'),
161 'unique' => 'filename',
162 'unique_method' => 'mtime',
163 'update_urls_in_files' => TRUE,
164 ),
165
166 // Add all files in the files/js directory, *but* update the URLs in the
167 // files. This is only necessary if we use JS aggregation.
168 3 => array(
169 'paths' => array('sites/wimleers.com/files/js'),
170 'pattern' => '.*',
171 'ignored_dirs' => array('CVS'),
172 'unique' => 'filename',
173 'unique_method' => 'mtime',
174 'update_urls_in_files' => TRUE,
175 ),
176
177 // Add all Javascript, CSS, image and font files from our themes. But
178 // make sure the URLs don't break when CSS aggregation is disabled, by
179 // using the "common parent directory" unique level and the "md5 of mtimes"
180 // uniqueness method. We can revert to normal values if we have CSS
181 // aggregation enabled.
182 4 => array(
183 'paths' => array('sites/default/themes/garland-customized'),
184 '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.
185 'ignored_dirs' => array('CVS'),
186 'unique' => 'common parent directory',
187 'unique_method' => 'md5 of mtimes',
188 ),
189 ),
190 'cdn_sync_method' => 'ftp',
191 'cdn_sync_method_settings' => array(
192 'host' => 'ftp.cachefly.com',
193 'remote_path' => 'wimleers.com',
194 'port' => 21,
195 'user' => 'user',
196 'pass' => 'pass',
197 ),
198 );
199
200
201 Author
202 ------
203 Wim Leers
204
205 * mail: work@wimleers.com
206 * website: http://wimleers.com/work
207
208 The author can be contacted for paid customizations of this module as well as
209 Drupal consulting, development and installation.

  ViewVC Help
Powered by ViewVC 1.1.2