Hello,
I've moved an average sized website (22.000+ pages) into CakePHP
(Version 3825, 2006-11-03) and I've found some results and issues I'd
like to share.
First of all, the routing mechanism -and please correct me if I'm
wrong- is not correctly working with view caching. I make heavy use of
routes in the shake of user friendlyness and search engine
optimization, so the 'controller/view/parameter' paradigm doesn't fit
my URIs in most cases, and the cache mechanism works incorrecly under
this circumstance:
Views with $_POST data were actually being cached, which included
sometimes failed user logins being cached and thus passwords stored in
the static generated view. Also, views weren't deleted after an INSERT,
UPDATE, or DELETE operations, because they tried to delete a cache file
stored under the 'controller_view_parameter.php' format, which is not
always true when routing is used.
I've temporary solved this by patching tow CakePHP files under the
/cake/ directory like this:
/cake/bootstrap.php, around line #107:
BEFORE:
if (file_exists($filename)) {
...
} elseif(file_exists(CACHE . 'views' . DS . convertSlash($uri) .
'_index.php')) {
...
}
AFTER:
if (empty($_POST)) {
if (file_exists($filename)) {
...
} elseif(file_exists(CACHE . 'views' . DS . convertSlash($uri) .
'_index.php')) {
...
}
} else {
clearCache(convertSlash($uri));
}
/cake/libs/view/helpers/cache.php, around line #192:
BEFORE:
function __writeFile($file, $timestamp) {
$now = time();
AFTER:
function __writeFile($file, $timestamp) {
if (!empty($_POST)) return;
$now = time();
Second, there is an issue about caching that can lead to a perfomance
leak. Despite I'm generating cached views only for the most used and
resource-consumpting controllers, my /app/tmp/cache/views directory is
populated now by 8015 files, and site caching has only been up for the
past 24 hours, so I expect them to be much more on the next weeks
(around 22.000, I think).
As far as I've heard this is not optimal because the OS kernel will
need to read up the full directory entry and search among various
thousands of files, which is a CPU consumpting task. I'm considering
patching the cache functions in order to have the cached views stored
in subdirectories ordered by their first character. Something like
/views/a/, /views/b/, and so on.
Anyway, and in spite of this little issues, the view cache has
*dramatically* reduced my server's load and the number of queries per
hour.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---