Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-18-2014, 03:14 AM
findingpeace's Avatar
findingpeace findingpeace is offline
 
Join Date: Nov 2011
Posts: 268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Template caching doesn't seem to be working

In my config.php file, I have the following line enabled:

Code:
$config['Datastore']['class'] = 'vB_Datastore_XCache';
Server shows xcache installed:

Code:
PHP 5.4.20 (cli) (built: Oct 14 2013 16:02:24)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with XCache v3.0.3, Copyright (c) 2005-2013, by mOo
    with the ionCube PHP Loader v4.4.1, Copyright (c) 2002-2013, by ionCube Ltd.
    with XCache Cacher v3.0.3, Copyright (c) 2005-2013, by mOo
Caching isn't disabled in ACP-->Options-->Server/Optimization Options.

So here's the problem - I have many templates cached via plugins in the cache_templates hook like so:

Code:
$cache[] = 'mytemplate';
But these templates aren't caching at all. For example, I have the "DBTech Thank You Hack" installed (shows recent "Thanks" in a memberinfo tab), so I tried refreshing on the memberinfo page every few seconds, but the debugger still shows the same number of queries. I don't have any new "Thanks" but it's still running 20 big queries on the same 20 recent members who thanked me. All just to get their username and post link (which it should already have in cache from my refresh moments ago!)

Every single refresh, it runs this query 20 times:

Code:
SELECT 
	userfield.*, usertextfield.*, user.*, UNIX_TIMESTAMP(passworddate) AS passworddate, user.languageid AS saved_languageid,
	IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline, customavatar.width AS avwidth, customavatar.height AS avheight, customavatar.height_thumb AS avheight_thumb, customavatar.width_thumb AS avwidth_thumb, customavatar.filedata_thumb
	, bu.bloguserid, bu.entries, bu.options AS blog_options, bu.subscribeown AS blog_subscribeown, bu.memberids, bu.memberblogids,
bu.subscribeothers AS blog_subscribeothers, bu.title AS blog_title, bu.description AS blog_description, bu.allowsmilie AS blog_allowsmilie, bu.draft AS blog_draft, bu.pending AS blog_pending, bu.options_member, bu.options_guest, bu.options_buddy, bu.options_ignore, bu.uncatentries, bu.moderation AS blog_moderation, bu.deleted AS blog_deleted, bu.akismet_key AS blog_akismet_key, isblogmoderator, bu.comments_moderation AS blog_comments_moderation, bu.lastblog, bu.lastblogid, bu.lastblogtitle, bu.categorycache, bu.tagcloud, bu.sidebar, bu.custompages, bu.customblocks, blockparsed.blocktext, 1 AS blogstyleid, blog_usercsscache.csscolors AS blog_csscolors, blog_usercsscache.cachedcss AS blog_cachedcss, IF(blog_usercsscache.cachedcss IS NULL, 0, 1) AS blog_hascachedcss, blog_usercsscache.buildpermissions AS blog_cssbuildpermissions, gm.permissions AS grouppermissions, ignored.relationid AS ignoreid, buddy.relationid AS buddyid, IF(blog_subscribeuser.blogsubscribeuserid, 1, 0) AS blogsubscribed, customprofilepic.userid AS profilepic, customprofilepic.dateline AS profilepicdateline, customprofilepic.width AS ppwidth, customprofilepic.height AS ppheight
FROM vbuser AS user
LEFT JOIN vbuserfield AS userfield ON (user.userid = userfield.userid)
LEFT JOIN vbusertextfield AS usertextfield ON (usertextfield.userid = user.userid) LEFT JOIN vbavatar AS avatar ON (avatar.avatarid = user.avatarid) LEFT JOIN vbcustomavatar AS customavatar ON (customavatar.userid = user.userid) 

LEFT JOIN vbblog_user AS bu ON (bu.bloguserid = user.userid)
LEFT JOIN vbblog_custom_block_parsed AS blockparsed ON (blockparsed.userid = user.userid AND blockparsed.styleid = 1 AND blockparsed.languageid = 1)
LEFT JOIN vbuserlist AS ignored ON (ignored.userid = user.userid AND ignored.relationid = 1 AND ignored.type = 'ignore')
LEFT JOIN vbuserlist AS buddy ON (buddy.userid = user.userid AND buddy.relationid = 1 AND buddy.type = 'buddy')
LEFT JOIN vbblog_groupmembership AS gm ON (user.userid = gm.bloguserid AND gm.userid = 1)
LEFT JOIN vbblog_subscribeuser AS blog_subscribeuser ON (user.userid = blog_subscribeuser.bloguserid AND blog_subscribeuser.userid = 1)
LEFT JOIN vbblog_usercsscache AS blog_usercsscache ON (user.userid = blog_usercsscache.userid)
LEFT JOIN vbcustomprofilepic AS customprofilepic ON (user.userid = customprofilepic.userid)
WHERE user.userid = #### LIMIT 1
Add on the tags/quotes mod, and my member info page gets REALLY slow.

Shouldn't template caching ultimately result in fewer queries every few reloads?

Thanks!
Reply With Quote
  #2  
Old 08-18-2014, 04:19 AM
ForceHSS ForceHSS is offline
 
Join Date: Apr 2008
Posts: 6,357
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you checked with your host to make sure it really is installed also check server error logs
Reply With Quote
  #3  
Old 08-18-2014, 06:00 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That query isn't to fetch a template, its a query to fetch data.

The datastore doesn't cache templates either.

The cache doesn't cache the page output either.

I don't think the cache you're looking at does what you think it does.
Reply With Quote
Благодарность от:
CAG CheechDogg
  #4  
Old 08-18-2014, 06:06 AM
CAG CheechDogg's Avatar
CAG CheechDogg CAG CheechDogg is offline
 
Join Date: Feb 2012
Location: Riverside, California USA
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmmm..interesting .....
Reply With Quote
  #5  
Old 08-18-2014, 11:02 AM
findingpeace's Avatar
findingpeace findingpeace is offline
 
Join Date: Nov 2011
Posts: 268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks everyone! This is very interesting. I'm trying to learn a lot more about optimizing vBulletin, and I've come pretty far on most pages! Cut down load times from 2 seconds to .5 seconds (and CMS from 8 seconds to .7 seconds). A lot of these had to do with old poorly designed mods.

But this memberinfo / template caching has me confused. I guess my question here would be, how can I just keep that fetch data query cached for a few minutes, so it doesn't need to reload every time?

I figured out that query seems to be coming from fetch_avatar_url, which I use to show the avatar of the "Thanker". Why in the world does it need all of that data in the query? Can't it just grab the avatar info? And again, same question as above, how can I keep this information cached so it doesn't run the query every time?

For example, when I look at the queries on a regular posting thread, I don't see that fetch data query run once. And yet magically, I still see everyone's avatar and username on the page!

--------------- Added [DATE]1408372276[/DATE] at [TIME]1408372276[/TIME] ---------------

Ah bummer. Found the problem in functions_user.php:

Code:
function fetch_avatar_url($userid, $thumb = false)
/*
	Changed the code to only use the cache for $avatarinfo.
	The problem with caching the url as well is that if you have already called
	this function with $thumb = false you cannot then call it with $thumb = true (or vice versa).
*/
C'mon vb developers!

As a solution, I will rewrite this as two functions, one for thumbnail, one for non-thumbnail. That way both can cache.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:02 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03512 seconds
  • Memory Usage 2,209KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (1)post_thanks_box_bit
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete