4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Kane on February 02, 2006, 03:54:56 PM
-
As of now we can cache the gallery home page, the categories page, but NOT the images page itself. Why??? It seems obvious that the images page is the page that will be hit the hardest and therefore should be cached as well.
-
what are you talking about?
-
what are you talking about?
From what I understand you can cache the home.html page and the categories.html page but not the details.html. The details.html page is the page where the images reside. Or maybe you can cache that page and I am wrong?
-
Well, yes, your are correct. But, if you think about what the cache feature does, then it actualy has no use on details page, simply because - how many times a visitor will visit same image?
The cache feature saves compilled pages into files and use them next time same visitor opened that page again, instead of compilling the page again. To avoid any security breach, the cached pages are unique for each visitor, that means that one visitor will not see somebody's else cached pages...(guests are exeption)
Because home and categories pages are most intensive (perfomance wise) for the server, they are cached, but details page does not require much server resources, and is much more dynamic then any other pages (each image has its own data to be displayed), that's why its pointless cache it.
-
That's true but my website gets linked by huge sites pretty often and I'll have a couple thousand guest users all visiting the same image. If this page were cached it would help out a lot on my server.
-
Ok, I have not tested this code, so try it on your own risk ;)
in details.php find:$random_cat_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image($cat_id);
Insert above:$cache_id = create_cache_id(
'details',
array(
$user_info[$user_table_fields['user_id']],
$image_id,
$mode,
isset($user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 0, 8) : 0,
$config['template_dir'],
$config['language_dir']
)
);
if (!$cache_page_categories || !$content = get_cache_file($cache_id)) {
// Always append session id if cache is enabled
if ($cache_page_categories) {
$old_session_mode = $site_sess->mode;
$site_sess->mode = 'get';
}
ob_start();
Then find:include(ROOT_PATH.'includes/page_footer.php');
Insert above:$content = ob_get_contents();
ob_end_clean();
if ($cache_page_categories) {
// Reset session mode
$site_sess->mode = $old_session_mode;
save_cache_file($cache_id, $content);
}
} // end if get_cache_file()
echo $content;
-
You're a genius, it worked. Thank you very much.
-
but if you got a lot of images,
the your cache folder can be get very full of cached pages,
cause the image are also cached, right?
-
actualy this only cache the compilled HTML code of the page ;)
-
ah, ok i see.
i never used the cache function before,
and thought that the images were also get cached in the compiled html file instead of linking to them.
-
For my gallery I set the cache for four hours, replaced "getimagesize" in function.php with filesize, and now applied this current hack to cache the images page. And now my server load has been reduced by about 70% and pages loads MUCH faster. I'm still looking for more ways to better optimize 4images for large websites (I get over 20,000 visiters daily) but for now it's working great.
-
It works great, but what if I am using mod with big pictures( /big directory for original images)
When i click on image it wont direct you to original image.