/[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.10 - (show annotations) (download)
Sat Jan 12 16:19:17 2008 UTC (22 months, 1 week ago) by wimleers
Branch: MAIN
Changes since 1.9: +2 -2 lines
File MIME type: text/plain
Explained why CSS files of themes even should be synchronized when CSS aggregation is enabled.
1 // $Id: README.txt,v 1.9 2008/01/12 15:26:55 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 < drupal_core_cdn_integration.patch
80
81 To undo the patch:
82 patch -p0 -R < drupal_core_cdn_integration.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.
87
88
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 Setting up CDN synchronization filters
99 --------------------------------------
100 First of all: each filter works *recursively*! Now, the explanations:
101 - 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 - pattern: Regular expression that will be used to filter the files in each
104 directory. Like the $mask parameter in file_scan_directory().
105 - ignored_dirs: Array of directories that should be ignored in each directory.
106 Like the $nomask parameter in file_scan_directory().
107 - 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 Currently supported: 'mtime' (the file's mtime property),
114 'md5' (md5 hash of the file) or 'md5 of mtimes' (md5 hash of
115 the concatenated mtimes of a set of files). This last option
116 is only available if you have set the unique property to
117 'common parent directory'.
118
119
120 Configuring the $conf array in settings.php
121 -------------------------------------------
122 This is my configuration:
123
124 $conf = array(
125 'cdn_url' => 'http://wimleers.cachefly.com/wimleers.com',
126 'cdn_sync_filters' => array(
127 // Add all Javascript, CSS, image and flash files from the most common
128 // directories in Drupal.
129 0 => array(
130 'paths' => array('misc', 'profiles', 'modules', 'sites/all/modules', 'sites/default/modules'),
131 'pattern' => '.*\.(js|css|gif|png|jpg|jpeg|svg|swf)$',
132 'ignored_dirs' => array('CVS'),
133 'unique' => 'filename',
134 'unique_method' => 'mtime',
135 ),
136
137 // We want to add *everything* in the files directory. Except for the
138 // files in the CSS directory, because they need special treatment.
139 1 => array(
140 'paths' => array('sites/wimleers.com/files'),
141 'pattern' => '.*',
142 'ignored_dirs' => array('CVS', 'css'),
143 'unique' => 'filename',
144 'unique_method' => 'mtime',
145 ),
146
147 // Add all files in the files/css directory, *but* update the URLs in the
148 // files. This is only necessary if we use CSS aggregation.
149 2 => array(
150 'paths' => array('sites/wimleers.com/files/css'),
151 'pattern' => '.*',
152 'ignored_dirs' => array('CVS'),
153 'unique' => 'filename',
154 'unique_method' => 'mtime',
155 'update_urls_in_files' => TRUE,
156 ),
157
158 // Add all Javascript, CSS, image and font files from our themes. But
159 // make sure the URLs don't break when CSS aggregation is disabled, by
160 // using the "common parent directory" unique level and the "md5 of mtimes"
161 // uniqueness method. We can revert to normal values if we have CSS
162 // aggregation enabled.
163 3 => array(
164 'paths' => array('sites/default/themes/garland-customized'),
165 '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.
166 'ignored_dirs' => array('CVS'),
167 'unique' => 'common parent directory',
168 'unique_method' => 'md5 of mtimes',
169 ),
170 ),
171 'cdn_sync_method' => 'ftp',
172 'cdn_sync_method_settings' => array(
173 'host' => 'ftp.cachefly.com',
174 'remote_path' => 'wimleers.com',
175 'port' => 21,
176 'user' => 'user',
177 'pass' => 'pass',
178 ),
179 );
180
181
182 Author
183 ------
184 Wim Leers
185
186 * mail: work@wimleers.com
187 * website: http://wimleers.com/work
188
189 The author can be contacted for paid customizations of this module as well as
190 Drupal consulting, development and installation.

  ViewVC Help
Powered by ViewVC 1.1.2