View Full Version : Offline Template Compressor
Andreas
07-12-2004, 10:00 PM
This hack is similar to Logicians Realtime Template Compressor
(https://vborg.vbsupport.ru/showthread.php?t=56589), but uses
a slightly different approach:
Instead of doing the compression realtime when the pages are
generated, it compresses the templates right in the database when they
are being saved, so there will be zero overhead during normal operation.
The templates will still look normal when you edit them, just the
parsed versions will be compressed.
Currently this hack does not touch JavaScript, so there should be
no issues with that.
(JavaScript could also be compressed, but then there must be no
comments in it)
Results may vary, but this could reduce traffic approx. 5-10%,
even if you use GZip (recommended).
Details
-------
Difficulty: Easy
Files to modify: 1
Thanks for sharing your hack with the community
corsacrazy
07-13-2004, 11:22 PM
what improovments on load time ?
MrNase
07-14-2004, 03:59 AM
Nett :)
* MrNase clicks install...
NuclioN
07-14-2004, 06:27 AM
How do you create a setting in "vBulletin Options/Server Settings and Optimization Options" ??
TheComputerGuy
07-14-2004, 12:20 PM
How do you create a setting in "vBulletin Options/Server Settings and Optimization Options" ??
I believe you have to have debug turned on in the config.php
Princeton
07-18-2004, 05:02 PM
great job!
Boofo
07-18-2004, 05:10 PM
So if we purposely used a space anywhere in the templates we will need to make it then to get the space back after compressing?
Andreas
07-18-2004, 10:23 PM
Yes, this might be necessary, although I tried to add some code to preserve spaces that are there intentionally, eg. for layout purposes.
I am having trouble getting the files in the phpinclude_start to run. Like the phreak statisick counter and my $banner software.
Any ideas?
Andreas
08-01-2004, 08:48 PM
Can you post your phpinclude_start template?
Sure can,
// Example of how to include a separate file:
// ob_start();
// require("yourheader.html");
// $header = ob_get_contents();
// ob_end_clean();
$hour = vbdate("G");
$greeting = "$vbphrase[goodevening] $bbuserinfo[username].";
if( $hour < 18 ) { $greeting = "$vbphrase[goodafternoon] $bbuserinfo[username]."; }
if( $hour < 12 ) { $greeting = "$vbphrase[goodmorning] $bbuserinfo[username]."; }
ob_start();
require("./forums/banner.php");
$banners = ob_get_contents();
ob_end_clean();
include("./statistik_counter.php");
It works when I decompress but not while compressed.
I made a phpinclude.php file and then did and include('phpinclude.php') to my index.php but still not luck.
When I View Source of the main page the area where the banners come up is missing the code from the $banner it looks like this:
<td align="left" width="468" height="60"></td>
I should add that the greeting hack quits working while the templates are in compression.
Andreas
08-01-2004, 10:10 PM
Hmm, I don't know why vBulletin does call compile_template() on phpinclude_start as there should be nothing to do in this template ...
Anyway, try to remove
// Example of how to include a separate file:
// ob_start();
// require("yourheader.html");
// $header = ob_get_contents();
// ob_end_clean();
I couldn't test the banner & statistics stuff as I don't have the files, but the greeting seems to work then.
That did it, very odd but dosent' matter as long as it work,, right. lol
Andreas
08-01-2004, 11:12 PM
It's not thaaat odd:
As vBulletin calls compile_template() your phpinclude_start template will be compress, so afterwards it will look similar to this:
// Example of how to include a separate file: // ob_start(); // require("yourheader.html"); // $header = ob_get_contents(); // ob_end_clean(); $hour = vbdate("G"); $greeting = "$vbphrase[goodevening] $bbuserinfo[username]."; if( $hour < 18 ) { $greeting = "$vbphrase[goodafternoon] $bbuserinfo[username]."; } if( $hour < 12 ) { $greeting = "$vbphrase[goodmorning] $bbuserinfo[username]."; } ob_start(); require("./forums/banner.php"); $banners = ob_get_contents(); ob_end_clean(); include("./statistik_counter.php");
eg. one line - which is commented out (and thus will not be executed)
Tailfeathers
08-02-2004, 01:34 AM
Nice:)
Very nice. I feel an Performance +
HELP!
I upped the master-style again.
And if i reply now on a Thread it looks like here (http://www.board-insel.de/zeugs/failure.JPG). This failure only comes with every Browser.
Everything else went fine. It comes only if your logged in, isnt that strange?
Thank you in advance!!
##edit##
Here is my newreply template:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head><title>$vboptions[bbtitle] - $vbphrase[reply_to_topic]</title>
$headinclude
</head>
<body$onload>
$header
$navbar
<form action="newreply.php" name="vbform" method="post"<if condition="!is_browser('webtv')"> onsubmit="return validatePost(this, 0, $vboptions[postminchars], $vboptions[postmaxchars]);" onreset="vB_RESET(this);"</if>>
$postpreview
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">
<span class="smallfont" style="float:$stylevar[right]"><strong>$vbphrase[thread]</strong>: <a href="showthread.php?$session[sessionurl]t=$threadinfo[threadid]">$threadinfo[title]</a></span>
$vbphrase[reply_to_thread]
</td>
</tr>
<tr>
<td class="panelsurround" align="center">
<div class="panel">
<div style="width:$stylevar[formwidth]" align="$stylevar[left]">
$usernamecode
<!-- subject field -->
<table cellpadding="0" cellspacing="0" border="0" class="fieldset">
<tr>
<td class="smallfont" colspan="3">$vbphrase[title]:</td>
</tr>
<tr>
<td><input type="text" class="bginput" name="title" value="$title" size="50" maxlength="85" tabindex="1" title="$vbphrase[optional]" /></td>
<td> </td>
<td><img id="display_posticon" src="$selectedicon[src]" alt="$selectedicon[alt]" /></td>
</tr>
</table>
<!-- / subject field -->
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<!-- message area -->
<div class="smallfont">$vbphrase[message]:</div>
$messagearea
<!-- / message area -->
$posticons
</td>
</tr>
</table>
</div>
</div>
<div style="margin-top:$stylevar[cellpadding]px">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="do" value="postreply" />
<input type="hidden" name="t" value="$threadid" />
<input type="hidden" name="p" value="$postid" />
<input type="hidden" name="posthash" value="$posthash" />
<input type="hidden" name="poststarttime" value="$poststarttime" />
<input type="submit" class="button" name="sbutton" value="$vbphrase[submit_reply]" accesskey="s" tabindex="1" />
<input type="submit" class="button" name="preview" value="$vbphrase[preview_post]" accesskey="p" tabindex="1" />
</div>
</td>
</tr>
</table>
<br />
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<thead>
<tr>
<td class="tcat">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('newpost_options')"><img id="collapseimg_newpost_options" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_newpost_options].gif" alt="" border="0" /></a>
$vbphrase[additional_options]
</td>
</tr>
</thead>
<tbody id="collapseobj_newpost_options" style="$vbcollapse[collapseobj_newpost_options]">
<tr valign="top">
<td class="panelsurround" align="center">
<div class="panel">
<div style="width:$stylevar[formwidth]" align="$stylevar[left]">
<fieldset class="fieldset">
<legend>$vbphrase[miscellaneous_options]</legend>
<div style="padding:$stylevar[formspacer]px">
<if condition="$bbuserinfo['signature'] != ''"><div><label for="cb_signature"><input type="checkbox" name="signature" value="1" id="cb_signature" tabindex="1" $checked[signature] />$vbphrase[show_your_signature]</label></div></if>
<div><label for="cb_parseurl"><input type="checkbox" name="parseurl" value="1" id="cb_parseurl" tabindex="1" $checked[parseurl] />$vbphrase[automatically_parse_links_in_text]</label></div>
$disablesmiliesoption
</div>
</fieldset>
$attachmentoption
<fieldset class="fieldset">
<legend>$vbphrase[thread_subscription]</legend>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
<tr>
<td>$vbphrase[notification_type]:<br /><select name="emailupdate" tabindex="1">
<option value="9999" $emailchecked[9999]>$vbphrase[do_not_subscribe]</option>
<option value="0" $emailchecked[0]>$vbphrase[no_email_notification]</option>
<option value="1" $emailchecked[1]>$vbphrase[instant_email_notification]</option>
<option value="2" $emailchecked[2]>$vbphrase[daily_email_notification]</option>
<option value="3" $emailchecked[3]>$vbphrase[weekly_email_notification]</option>
</select></td>
<if condition="$show['subscribefolders']"><td>$vbphrase[folder]:<br /><select name="folderid" tabindex="1">$folderbits</select></td></if>
</tr>
</table>
</fieldset>
<if condition="$show['threadrating']">
<fieldset class="fieldset">
<legend>$vbphrase[rate_thread]</legend>
<div style="padding:$stylevar[formspacer]px">
<div>$vbphrase[can_add_a_score_for_thread]</div>
<div>
<select name="rating" tabindex="1">
<option value="0"$rate[0]>$vbphrase[choose_a_rating]</option>
<optgroup>
<option value="5"$rate[5]>5 : $vbphrase[excellent]</option>
<option value="4"$rate[4]>4 : $vbphrase[good]</option>
<option value="3"$rate[3]>3 : $vbphrase[average]</option>
<option value="2"$rate[2]>2 : $vbphrase[bad]</option>
<option value="1"$rate[1]>1 : $vbphrase[terrible]</option>
</optgroup>
</select>
</div>
</div>
</fieldset>
</if>
$threadmanagement
</div>
</div>
<div style="margin-top:$stylevar[cellpadding]px">
<input type="submit" class="button" name="sbutton" value="$vbphrase[submit_reply]" accesskey="s" tabindex="1" />
<input type="submit" class="button" name="preview" value="$vbphrase[preview_post]" accesskey="p" tabindex="1" />
</div>
</td>
</tr>
</tbody>
</table>
</form>
<br />
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('threadreview')"><img id="collapseimg_threadreview" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_threadreview].gif" alt="" border="" /></a>
$vbphrase[topic_review_newest_first]
</td>
</tr>
</table>
$spacer_close
$spacer_open
<div id="collapseobj_threadreview" style="$vbcollapse[collapseobj_threadreview]">
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
$threadreviewbits
<if condition="$show['reviewmore']">
<tr>
<td class="tfoot" align="center" colspan="2"><span class="smallfont">
<phrase 1="$vboptions[maxposts]" 2="showthread.php?$session[sessionurl]t=$threadid">$vbphrase[thread_has_more_than_x_review]</phrase>
</span></td>
</tr>
</if>
</table>
</div>
$spacer_close
$spacer_open
<br />
$forumrules
$footer
</body>
</html>
##edit##
And if i want to start a new Thread it comes up, too.
It's really mystical that not all Usergroups are affected by this ( Every Group but not the Guests) Curios.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.