Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4257
Latest: Alex998.
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 43295
Total Topics: 7523
Most Online Today: 230
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 202
Total: 202

Author Topic: Using "cache_put_data" on SSI functions  (Read 4177 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Using "cache_put_data" on SSI functions
« on: November 02, 2014, 09:09:25 pm »
Is it possible to use this caching function on SSI functions?

For example, here is my SSI function being called somewhere on the website:

Code: [Select]
$what = ssi_recentTopics('10', $exclude_boards = array(29, 44, 17, 38, 53, 61), 'array');

echo '
<table cellpadding="1" cellspacing="0" width="100%" border="0">
<tr style="text-transform: uppercase;" class="catbg2">
<td class="smalltext" style="text-align: left; padding-top: 3px; padding-bottom: 3px;" colspan="2">Subject</td>
<td class="smalltext" style="text-align: center;">Replies</td>
<td class="smalltext" style="text-align: center;">Views</td>

<td class="smalltext" style="text-align: center;">Author</td>
<td class="smalltext" style="text-align: center;">Date</td>
</tr>';

$cnt = 1; foreach ($what as $topic) {
$cnt++;
    if ($cnt >= 2) $cnt = 0;

{
echo '
<tr>
<td width="8%" class="windowbg', $cnt == 0 ? '' : '2', '"><center>', $topic['icon'], '</center></td>
<td width="54%" class="windowbg', $cnt == 0 ? '' : '2', '" title="', $topic['preview'] ,'"><div style="overflow: hidden; height: 17px;">', $topic['link'], '</div>

<div class="smalltext"><b>', $topic['board']['link'], '</b></div>

</td>
<td width="8%" class="windowbg', $cnt == 0 ? '' : '2', '"><center>', $topic['replies'], '</center></td>
<td width="8%" class="windowbg', $cnt == 0 ? '' : '2', '"><center>', $topic['views'], '</center></td>

<td width="10%" class="windowbg', $cnt == 0 ? '' : '2', '"><center><div style="word-wrap: break-word; width: 100px;">', $topic['poster']['link'], '</div></center></td>
<td width="12%" class="windowbg', $cnt == 0 ? '' : '2', '" style="text-align:center;"><small>', $topic['time'], '</small></td>
</tr>';

} }

if(end($what))
echo'
<tr class="related">
<td colspan="6" style="text-align: center; background-color: #EEEEEE;">
<div class="smalltext extra_info" style="-webkit-backface-visibility: hidden;">
<img src="', $settings['images_url'], '/dots.gif" alt=""/> <a href="',$scripturl,'?action=recent" target="_blank">
View More Recently Updated Topics</a> <img src="', $settings['images_url'], '/dots_left.gif" alt=""/>
</div>
</td>
</tr>';

echo '
</table>

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Using "cache_put_data" on SSI functions
« Reply #1 on: November 02, 2014, 09:14:30 pm »
Yes it is you can do caching on it
Here is an example that does 60 seconds
Replace
Code: [Select]
$what = ssi_recentTopics('10', $exclude_boards = array(29, 44, 17, 38, 53, 61), 'array');
With
Code: [Select]
if (($what = cache_get_data('ssi_mainpagecache', 60)) == null)
{
$what = ssi_recentTopics('10', $exclude_boards = array(29, 44, 17, 38, 53, 61), 'array');

// Check if cache is enabled
global $modSettings;
if (!empty($modSettings['cache_enable']))
cache_put_data('ssi_mainpagecache', $what, 60);
}
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Using "cache_put_data" on SSI functions
« Reply #2 on: November 02, 2014, 10:41:16 pm »
Thank you for this, sir!

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Using "cache_put_data" on SSI functions
« Reply #3 on: November 02, 2014, 10:54:05 pm »
It is good to do for any data that isn't changing in a short period of time.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Using "cache_put_data" on SSI functions
« Reply #4 on: November 04, 2014, 11:30:06 pm »
Another similar question.

How would I put a full SSI function that I call in index.template.php in cache?

For example, I have this custom SSI function that I call on every page like this:

Code: [Select]
echo ssi_topPoster(7,'week');

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Using "cache_put_data" on SSI functions
« Reply #5 on: November 04, 2014, 11:34:07 pm »
Very similiar
Code: [Select]
if (($topPostercache = cache_get_data('ssi_toppostercache', 90)) == null)
{
$topPostercache = ssi_topPoster(7,'week');

// Check if cache is enabled
global $modSettings;
if (!empty($modSettings['cache_enable']))
cache_put_data('ssi_toppostercache', $topPostercache, 90);
}
   
   
    echo $topPostercache;
   
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Using "cache_put_data" on SSI functions
« Reply #6 on: November 05, 2014, 01:42:13 pm »
Wonderful :D

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Using "cache_put_data" on SSI functions
« Reply #7 on: November 05, 2014, 01:46:15 pm »
Keep on caching you can run a lot of sites on one server that way. I run like 50,000 forums off one server for very low cost.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Using "cache_put_data" on SSI functions
« Reply #8 on: November 06, 2014, 12:01:55 pm »
:o :o Insane, surely their are drawbacks AND I bet a lot of those forums are bone stock. How many queries do you get loaded per second, simultaneously?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Using "cache_put_data" on SSI functions
« Reply #9 on: November 06, 2014, 12:30:46 pm »
All sites hosted on createaforum.com my forum hosting service plus smfforfree.com and smfnew.com They also have gallery pro installed if they want it and alot of my other mods as well.

Not too bad one set of files for each domain and I have them all tweaked a ton.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
4472 Views
Last post May 21, 2007, 06:37:59 pm
by SMFHacks
1 Replies
8933 Views
Last post September 28, 2007, 11:46:07 am
by smalldonkey
2 Replies
8240 Views
Last post November 06, 2007, 08:55:18 pm
by dry3210
1 Replies
6629 Views
Last post March 26, 2011, 01:26:09 pm
by SMFHacks
8 Replies
8349 Views
Last post September 19, 2011, 02:00:29 pm
by VividViews

+- Recent Topics

Please Help! by SMFHacks
April 17, 2024, 08:04:55 am

Rate own images by fvlog19
April 11, 2024, 10:56:53 am

Tidy Child Boards on 2.1.4 by SMFHacks
April 04, 2024, 03:54:12 pm

Problems SMF 2.0.19 > 2.1.4 SMF Gallery Pro - Recents Images to overall header by Michel68
March 30, 2024, 12:41:08 pm

Can't DROP 'id_member'; check that column/key exists Datei: by SMFHacks
March 30, 2024, 11:58:20 am

No thumbnails on new uploads by Tonyvic
March 29, 2024, 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

Powered by EzPortal