/[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.6 - (show annotations) (download)
Tue Jan 8 10:16:29 2008 UTC (22 months, 3 weeks ago) by wimleers
Branch: MAIN
Changes since 1.5: +92 -10 lines
File MIME type: text/plain
Rewrote the README to its final form.
1 // $Id: README.txt,v 1.5 2008/01/08 02:45:40 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* 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 Installation
31 ------------
32 1) Place this module in your modules directory (this will usually be
33 "sites/all/modules/").
34
35 2) Enable the module.
36
37 3) Apply the Drupal core patch. See below.
38
39 4) Apply the theme patch to every theme. See below.
40
41 5) Read how to configure the CDN synchronization filters. See below.
42
43 6) Configure the $conf array in settings.php See below.
44
45 7) Copy cdn_cron.php to your Drupal root directory.
46
47 8) Configure cdn_cron.php like Drupal's cron.php. See http://drupal.org/cron.
48
49 9) Go to admin/logs/status. If the CDN integration module is installed
50 correctly or not, it will report so here.
51
52
53 Usage
54 -----
55 When the module is installed properly (see step 9 of the installation), you
56 can check the site-wide statistics at admin/settings/cdn. At that same page,
57 you can enable the per-page statistics as well. This will show the number of
58 files served from the CDN at the bottom of each page, as well as a list of
59 files that haven't been synchronized to the CDN yet, to users with the
60 "administer site configuration" permission.
61
62
63 Applying the Drupal core patch
64 ------------------------------
65 You *must* apply this patch!
66
67 First, change the directory to the Drupal root directory.
68
69 You can apply the included Drupal core patch like this:
70 patch -p0 < drupal_core_cdn_integration.patch
71
72 To undo the patch:
73 patch -p0 -R < drupal_core_cdn_integration.patch
74
75 Note: there is also a patch that combines the CDN integration core patch with
76 the JS aggregation. It's included in this module because if you apply both
77 patches separately, you will get a conflict.
78
79
80 Applying the theme patch
81 ------------------------
82 You *must* apply this patch to *every* theme that's being used on your website!
83
84 Repeat this process for every theme: first, change the directory to the
85 directory of the theme. Applying the patch is identical to the example above,
86 only with a different filename.
87
88
89 Setting up CDN synchronization filters
90 --------------------------------------
91 First of all: each filter works *recursively*! Now, the explanations:
92 - paths: This is an array of paths (each path being relative to the Drupal
93 root directory) on which this filter should be applied.
94 - pattern: Regular expression that will be used to filter the files in each
95 directory. Like the $mask parameter in file_scan_directory().
96 - ignored_dirs: Array of directories that should be ignored in each directory.
97 Like the $nomask parameter in file_scan_directory().
98 - unique: Determines how the uniqueness will be applied. You can set it to
99 'filename', which will alter the filename, or 'common parent
100 directory', which will alter the path of the file. The latter is
101 strongly recommended for themes, since it will not break URLs in
102 CSS files.
103 - unique_method: The method that should be used to generate unique filenames.
104 Currently supported: 'mtime' (the file's mtime property),
105 'md5' (md5 hash of the file) or 'md5 of mtimes' (md5 hash of
106 the concatenated mtimes of a set of files). This last option
107 is only available if you have set the unique property to
108 'common parent directory'.
109
110
111 Configuring the $conf array in settings.php
112 -------------------------------------------
113 This is my configuration:
114
115 $conf = array(
116 'cdn_url' => 'http://wimleers.cachefly.com/wimleers.com',
117 'cdn_sync_filters' => array(
118 // Add all Javascript, CSS, image and flash files from the most common
119 // directories in Drupal.
120 0 => array(
121 'paths' => array('misc', 'profiles', 'modules', 'sites/all/modules', 'sites/default/modules'),
122 'pattern' => '.*\.(js|css|gif|png|jpg|jpeg|svg|swf)$',
123 'ignored_dirs' => array('CVS'),
124 'unique' => 'filename',
125 'unique_method' => 'mtime',
126 ),
127
128 // We want to add *everything* in the files directory. Except for the
129 // files in the CSS directory, because they need special treatment.
130 1 => array(
131 'paths' => array('sites/wimleers.com/files'),
132 'pattern' => '.*',
133 'ignored_dirs' => array('CVS', 'css'),
134 'unique' => 'filename',
135 'unique_method' => 'mtime',
136 ),
137
138 // Add all files in the files/css directory, *but* update the URLs in the
139 // files. This is only necessary if we use CSS aggregation.
140 2 => array(
141 'paths' => array('sites/wimleers.com/files/css'),
142 'pattern' => '.*',
143 'ignored_dirs' => array('CVS'),
144 'unique' => 'filename',
145 'unique_method' => 'mtime',
146 'update_urls_in_files' => TRUE,
147 ),
148
149 // Add all Javascript, CSS, image and font files from our themes. But
150 // make sure the URLs don't break when CSS aggregation is disabled, by
151 // using the "common parent directory" unique level and the "md5 of mtimes"
152 // uniqueness method. We can revert to normal values if we have CSS
153 // aggregation enabled.
154 3 => array(
155 'paths' => array('sites/default/themes/garland-customized'),
156 'pattern' => '.*\.(js|css|gif|png|jpg|jpeg|otf)$',
157 'ignored_dirs' => array('CVS'),
158 'unique' => 'common parent directory',
159 'unique_method' => 'md5 of mtimes',
160 ),
161 ),
162 'cdn_sync_method' => 'ftp',
163 'cdn_sync_method_settings' => array(
164 'host' => 'ftp.cachefly.com',
165 'remote_path' => 'wimleers.com',
166 'port' => 21,
167 'user' => 'user',
168 'pass' => 'pass',
169 ),
170 );
171
172
173 Author
174 ------
175 Wim Leers
176
177 * mail: work@wimleers.com
178 * website: http://wimleers.com/work
179
180 The author can be contacted for paid customizations of this module as well as
181 Drupal consulting, development and installation.

  ViewVC Help
Powered by ViewVC 1.1.2