We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Overhead of using same weblog tag twice VS reeposition plugin - weblog tags cached per page or template?

Development and Programming

Meirion's avatar
Meirion
127 posts
17 years ago
Meirion's avatar Meirion

Hi, I was wondering if anyone could shed any light on this question about caching weblog tags.

I’m using

{exp:weblog:entries weblog="news" require_entry="yes"}

to pull out a single entry.

I am debating over methods of getting the page title into the title tag in my header embed…

Using same weblog tag twice

{embed="embeds/.htmlheader" title="{exp:weblog:entries weblog="news" require_entry="yes"}{title}{/exp:weblog:entries}"}

{exp:weblog:entries weblog="news" require_entry="yes"}
<h1>{title}
{body}
{/exp:weblog:entries}

or

Using reeposition plugin

{exp:reeposition} 

{embed="embeds/.htmlheader" title="{reeposition:put_item}"}

{exp:weblog:entries weblog="news" require_entry="yes"}
<h1>{reeposition:item}{title}{/reeposition:item}</h1>
{body}
{/exp:weblog:entries}

{/exp:reeposition}

I think I read somewhere that the results of the weblog tag are cached, so does this mean I can keep on reusing the same tag in a template and not hit the database any more?

Can I reuse the tag across several embeds and still have the benefit - ie is the cache per embed or per whole page request?

Am I better off using the reeposition plugin?

Your thoughts would be appreciated, please experts!

       
Mr. Wilson's avatar
Mr. Wilson
131 posts
17 years ago
Mr. Wilson's avatar Mr. Wilson

You may not find this helpful, but one of the best ways to test this sort of thing is to turn on template debugging; whip up a couple templates, one using each technique; repeatedly run each template; and compare the debugging info for each.

Generally speaking, EE’s DB caching mechanism allows it to not have to run the same queries over and over. (Note that not all queries are cachable.) So it’s true that subsequent runs of the exp:weblog:entries tag will require fewer DB hits than the first. But that’s not the only thing going on when you load exp:weblog:entries (or any tag) multiple times. You also need to think about the overhead associated with calling such a large and complex function over and over again.

Reeposition is little more than a cut and paste mechanism, so generally speaking it’s going to be pretty speedy relative to to the Weblog module’s entries() function. Speed might not be the only thing you’re interested in, though. You might value code maintainability, for example. I’ve seen some pretty convoluted uses of Reeposition, and while they work just fine, a developer unfamiliar with the plugin might not have any idea how to maintain the template code.

Is that any help?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.