Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Template Cache System Details »»
Template Cache System
Version: 2.5.4.0, by Trigunflame Trigunflame is offline
Developer Last Online: Nov 2019 Show Printable Version Email this Page

Version: 3.5.4 Rating:
Released: 03-11-2006 Last Update: 03-13-2006 Installs: 138
Code Changes Additional Files  
No support by the author.

Vbulletin Template Cache System
Optimize Your Forums!!


Notice:

While filesystem caching does provide a performance increase; it can be futher increased. I plan on including mmcache, eaccelerator, and APC shared memory support in the near future.

This will eliminate the need for reading/writing file to and from the filesystem.


Summary:

This modification will cache the templates that your forum uses to the file system saving you a mysql query.

Normally this data is requested from the database on every page load, with this however we cache all the templates we would normally use into a file to be included as a standard php code.

This will save you a pretty large query, the full size of the templates can be anywhere from 40kb to 200kb per page; even larger on some forums.

It will literally take 1 or 2 minutes to install, not long for the benefits that you receive.

PS. Use this in conjunction with my Other Hack (Compress Forum Templates) for speeding up your forum even more by compressing templates.
https://vborg.vbsupport.ru/showthread.php?t=107615
PS. Use this in conjunction with my Other Hack (Accelerated Plugins) for speeding up your forum even more by Inlining your plugins.
https://vborg.vbsupport.ru/showthread.php?t=107315


Instructions:

1. Download Zip File.
2. Read the INSTALL.txt
3. Click install if you like


Updates:
3/14/2006 8:34am : Large update, adding additional file locking code as well as moved some redundant code into functions. If you have an active site I recommend that you update with the newest version.

3/14/2006 7:07am : Cleaned up the code a little bit, no need to redo the edits unless you are a perfectionist like myself

3/13/2006 12:52 / Typo Update: There was a typo in the global.php edit, please re-do that step.

3/13/2006 11:48 / Massive Critical Update:
1. Automatically caches any uncached templates.
2. Files are now stored as .php files to prevent easy viewing.
I strongly recommend you update ASAP.
Just follow the INSTALL.txt and go through the procedures again.
PS. Make sure to empty the template_cache directory after upgrading. Thankyou.

3/12/2006 12:20pm
1. Now caches most action templates
2. The cache cleaner will not delete index.htm or index.html files.
3. Also updated the install.txt
4. Fixed parse error.
To upgrade, just re-do the code modifications listed in the install.txt file.
PLEASE clear the template_cache directory, after you redo the modifications. The new changes cache the actiontemplates as well.


Troubleshooting:

Start browsing your forum, going to your main page then browsing threads etc.. should start seeing items appear in that template_cache directory such as index_1.php, showthread_1.php etc.. if not you need to give this directory WRITE permissions (CHMOD 777)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #82  
Old 03-14-2006, 07:47 PM
dan35's Avatar
dan35 dan35 is offline
 
Join Date: Jul 2004
Location: California
Posts: 158
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

After I upgraded it from version 2.1 to 2.5.2 or 2.5.4, these scripts show twice on forumhome.

Members who have visited the forum (Today or last 24 hours).
https://vborg.vbsupport.ru/showthread.php?t=82769

Display count of unread posts in welcome box
https://vborg.vbsupport.ru/showthread.php?t=96522
Reply With Quote
  #83  
Old 03-14-2006, 07:50 PM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dan35
After I upgraded it from version 2.1 to 2.5.2 or 2.5.4, these scripts show twice on forumhome.

Members who have visited the forum (Today or last 24 hours).
https://vborg.vbsupport.ru/showthread.php?t=82769

Display count of unread posts in welcome box
https://vborg.vbsupport.ru/showthread.php?t=96522
Did you clear your cache directory after upgrading?
Reply With Quote
  #84  
Old 03-14-2006, 07:51 PM
dan35's Avatar
dan35 dan35 is offline
 
Join Date: Jul 2004
Location: California
Posts: 158
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes, I did.
Reply With Quote
  #85  
Old 03-14-2006, 07:58 PM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dan35
yes, I did.
Ask Paul, I havnt looked at the source of those 2 hacks; unless you didnt do something right with the install.. im not sure how he could be doing that.

Will look into it later.
Reply With Quote
  #86  
Old 03-14-2006, 08:03 PM
dan35's Avatar
dan35 dan35 is offline
 
Join Date: Jul 2004
Location: California
Posts: 158
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your version 2.1 works fine.
Reply With Quote
  #87  
Old 03-15-2006, 03:03 AM
Reef Reef is offline
 
Join Date: May 2003
Location: USA
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is a cool addition but I have a double welcome panel after it gets cached.

I did clear the cache a couple tmes and get the same results after the second page load..

see attachment

EDIT:

I now also noticed my "Who has viewed thread" hack is no longer showing up
Reply With Quote
  #88  
Old 03-15-2006, 09:06 AM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Will work on it later, its always the damn plugins.
Reply With Quote
  #89  
Old 03-15-2006, 09:15 AM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Reef
This is a cool addition but I have a double welcome panel after it gets cached.

I did clear the cache a couple tmes and get the same results after the second page load..

see attachment


EDIT:

I now also noticed my "Who has viewed thread" hack is no longer showing up
Ps. Did you do a clean install of this modification as well? Between 2.5.0 and 2.5.4 were lots of changes.
Reply With Quote
  #90  
Old 03-15-2006, 12:55 PM
MentaL's Avatar
MentaL MentaL is offline
 
Join Date: Jan 2003
Posts: 550
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

those wanting to sort global.php back to original

search

Code:
($hook = vBulletinHook::fetch_hook('cache_templates')) ? eval($hook) : false;
below , delete

Code:
// now get all the templates we have specified
/**
 * @author Dusty Burns (Trigunflame@charter.net)
 * @copyright 2006-2007 Dusty Burns
 * @package Vbulletin Template Cache
 * @version 2.5.0.0
 * @todo Add Shared Memory Support
 */

/*
 * Is this actually necessary? 
 * 
 * Probably not, but right now I don't want hacks 
 * whos authors did not copy the define() for 
 * THIS_SCRIPT and change it; causing us to get
 * the wrong cache and screwing the page up.
 * 
 * This basically makes sure that THE_SCRIPT does 
 * correspond to the actual filename being requested.
 * 
 * PS. You can change .php down below this to whatever 
 * file ext you use for Your PHP files: ie .php4,.php5
 */
if (THIS_SCRIPT == basename($vbulletin->script, '.php'))
{
    // Cache Templates
    $vbulletin->cache_templates = true;
    
    /*
     * It is nice to have some sort of function 
     * for locking while writing data. We could 
     * just use flock, but for the sake of 
     * conforming to how jelsoft does some things.
     * 
     * Begin Generic Lock
     */
    function tpl_cache_lock()
    {
        global $db;
        $lock_attempts = 5;
        while ($lock_attempts >= 1)
        {
            $result = $db->query_write(
                'UPDATE ' . TABLE_PREFIX . 'adminutil SET ' .
                'text = UNIX_TIMESTAMP() ' .
                "WHERE title = 'datastorelock' " . 
                'AND text < UNIX_TIMESTAMP() - 15'
            );
            if ($db->affected_rows() > 0) { return true; } else { $lock_attempts--; sleep(1); }
        }
        return false;
    }
    
    function tpl_cache_unlock()
    {
        global $db;
        $db->query_write(
            'UPDATE ' . TABLE_PREFIX . 'adminutil ' . 
            "SET text = 0 WHERE title = 'datastorelock'"
        );
    }
    /*
     * End Generic Lock
     */

    // Check Existance
    $tpl_cache_name = DIR . '/template_cache/' . THIS_SCRIPT . '_' . STYLEID . '.php';
                        
    // Look For Cached File
    if (@include($tpl_cache_name))
    {
        // Fake Cached Templates & Update Style
        cache_templates(array(), $style['templatelist']);
    }
    // Write Cache
    else
    {
        // Build Template Cache
        cache_templates($globaltemplates, $style['templatelist']);
        
        // Get File Lock
        if (tpl_cache_lock())
        {
            $tpl_cache = "<?php\r\n" . '$vbulletin->templatecache = ' . 
            var_export($vbulletin->templatecache, true) . ';' . "\r\n?>";

            // Debugging Purposes
            if ($fp = @fopen($tpl_cache_name, 'w+'))
            {
                @fwrite($fp, $tpl_cache);
                @fclose($fp);
                unset($tpl_cache);
                tpl_cache_unlock();
            }
            // Could Not Create File
            else
            {
              tpl_cache_unlock();
              exit("Could not cache template file. The template_cache dir must be writable (CHMOD 777).");
            }
        }
    }
}
// Vbulletin Default
else
{
    // now get all the templates we have specified
    cache_templates($globaltemplates, $style['templatelist']);
}
unset($globaltemplates, $actiontemplates, $_get_edit_templates, $_templatedo);
replace with

Code:
// now get all the templates we have specified
cache_templates($globaltemplates, $style['templatelist']);
unset($globaltemplates, $actiontemplates, $_get_edit_templates, $_templatedo);
i believe thats original
Reply With Quote
  #91  
Old 03-15-2006, 07:31 PM
Trigunflame's Avatar
Trigunflame Trigunflame is offline
 
Join Date: Aug 2002
Posts: 742
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 11:29 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.04849 seconds
  • Memory Usage 2,324KB
  • Queries Executed 25 (?)
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
  • (3)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete