Active
Project:
Droptor
Version:
6.x-3.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Issue tags:
Reporter:
Created:
16 Feb 2011 at 13:43 UTC
Updated:
9 Sep 2011 at 09:28 UTC
I'm looking into enabling aggressive caching mode on a site of mine. One of the modules that may stop working properly, is the droptor module. It seems hook_init() is necessary only to know the script's start time. This could be worked around by moving the code out of the function, directly into the module's PHP code:
global $script_start_time;
$script_start_time = microtime(true);
instead of
function droptor_init() {
global $script_start_time;
$script_start_time = microtime(true);
}
However, I have no idea how we could still keep the memory monitoring that resides in hook_exit() operational while enabling aggressive caching. Do you have any suggestions?
Comments
Comment #1
jemond commentedHi Wim,
Thanks for your note.
First off, it looks like I need to move hook_init() to hook_boot(), as hook_boot() is run for normally cached pages but hook_init() isn't. Your note made me realize this, so thanks! (This is now committed to the v3 branch.)
As for supporting aggressive caching (AC) and memory logging, this isn't possible. AC by design skips hook_boot() and hook_exit(), which are vital to make memory logging work. However, Droptor will still work fine with aggressive caching, you just won't get additional memory data for anonymous traffic.
I also don't want to move the start time outside of a module function as I think this isn't Drupal best practices, if I understand correctly.
Kindly let me know if you have any other questions or if there is anything else I can do to help.
Thanks,
jpe
Comment #2
wim leersHeh, glad to unconsciously be of help :)
And thanks for confirming what I thought. I think you may want to document this. I'm going to go ahead and enable aggressive caching on http://driverpacks.net — this will indeed remove many of the memory reports, but that's okay, because there's less PHP involved anyway, that way.
However, now that I think of it, why can't you just use drupal_register_shutdown_function() (or just PHP's own register_shutdown_function() instead? That would *always* work. That's how devel does it, too.
Comment #3
jemond commentedHi Wim,
That is a neat idea. I hadn't thought of that.
I will see if I can get this into the next version of the module. Will update.
jpe
Comment #4
wim leersOk, great! Thanks! :)
Comment #5
xjmRegarding using drupal_register_shutdown_function() -- where could you register it that it would still get registered with aggressive caching enabled?
Comment #6
wim leershook_boot()Comment #7
xjmWhich gets skipped with aggressive caching. :)
Comment #8
wim leersThen I don't know/remember :)
However, AFAIK devel works with aggressive caching. We need to verify that. If it's true, then we just need to clone devel's approach.