Attached is a backport of the file-based caching patch originally written for Drupal 4.7, now working with Drupal 4.6.6. Being a new feature, it will of course not be merged into 4.6 (nor 4.7), but instead is simply being placed here to be available for anyone that needs it, and to further encourage testing of this patch. My goal is to get this functionality merged into Drupal 4.8. For 4.6, marking "won't fix".
To use, apply the patch from the top level Drupal directory (the same one that has index.php and cron.php). Then configure settings.php, being sure to create the directory you specify for cache files, making it writeable by the web server process serving Drupal pages. For absolute best performance enable FastPath in settings.php, however be sure to read and fully understand all comments about the new features in the settings.php file first.
Additional discussion about the file-based caching patch can be found here.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | cookies.png | 47.78 KB | agentrickard |
| filecache-4.6.6.patch.txt | 16.3 KB | jeremy |
Comments
Comment #1
agentrickardI think there is a problem with the setcookie() usage in session.inc. As used currently, the cookie for drupal_uid doesn't specify a path, which means that the cookie (at least in my test -- Firefox on Mac running Drupal 4.6.6 on Mac Apache / PHP 5) gets set for each system path.
See the attached.
I "fixed" this by changing the cookie function to mirror Drupal's sesion timeout limit and setting the path to "/":
- setcookie('drupal_uid', $user->uid);
+ $cookie_domain = ""; // the domain for the cookie
+ $cookie_time = time()+(60*60*24*30); // the cookie expiration time is today + 30 days
+ setcookie('drupal_uid', $user->uid, $cookie_time, "/", $cookie_domain);
If this behavior is "by design" let me know.
Comment #2
agentrickardI had a further problem.
When logging in, the drupal_uid cookie was always being set to 0.
I moved a copy of the cookie setting function (above) into user.module function user_login() and the problem corrected:
// Update the user table timestamp noting user has logged in.
db_query("UPDATE {users} SET changed = '%d' WHERE uid = '%s'", time(), $user->uid);
//
// If the file_cache and file_cache_fastpath are both enabled, this cookie
// will be used to determine whether or not a user is logged in without
// actually loading all the session information from the database.
$cookie_domain = ""; // the domain for the cookie
$cookie_time = time()+(60*60*24*30); // the cookie expiration time is today + 30 days
setcookie('drupal_uid', $user->uid, $cookie_time, '/', $cookie_domain);
Comment #3
nathandigriz commentedI could not get this to work on windows because a fatal error in using unlink(). Luckily I had a guy that knows more PHP around. This is what I got back from him.
Comment #4
agentrickardI had to add the following code to the DEVEL module during site testing, otherwise I couldn't clear my menu cache:
Comment #5
agentrickardThat DEVEL patch did not seem to do the trick. I tried using system_exit() and system_cron() to unlink all files in the $file_cache directory on demand, but neither works.
I think we need a function that allows manual emptying of the filesystem cache, or am I missing an existing feature?
Comment #6
agentrickardThe following does what I think I need, but may be overkill:
This allows for a manual flush of the filecache by the devel module.
Comment #7
magico commentedAs stated by the author will not be applied to 4.6, but stays here for whoever want to use it.