Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2010-04-24 14:01:31

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 259
Website

Re: aks_cache: Partial caching web pages. SpeedUp your site!

Yes! It was obvious, but not for me :-) Makss explained it in the help section <txp:aks_cache id='menu <txp:section />'>, but I overlooked it …

So I could convert all tags <txp:zem_cache ctx="xyz" /> to <txp:aks_cache id="xyz" /> and all <txp:zem_cache id="xyz" /> to <txp:aks_cache id='xyz-<txp:article_id />' />
zem_cache isn´t needed any more … Thanks Makss (дуже дякую)!

Offline

#12 2010-05-06 02:14:05

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: aks_cache: Partial caching web pages. SpeedUp your site!

hi Makss,
thanks for this plugin. I’m finally trying it and I like it.

However, I’m having some issues, and I’m not yet sure if this is a plugin issue or my fault.

The first issue I encounter is that, for aks_cache blocks where the id is created by using tags-in-tags, the plugin is creating two cache blocks.
For example:

cache block_id ttl(minutes) size(bytes)
noreset-last_tweets 60 727
noreset-otf_css_news 60 134
noreset-otf_css_ 60 126
site_vars_news 60 3
site_vars_ 60 3

last_tweets block is just a cache block created by using id="last_tweets".

On the other hand, otf_css and site_vars are blocks that are suffixed with <txp:section />, like this.

<txp:aks_cache id='site_vars_<txp:section />'>
  <txp:variable name="body_id"><txp:pax_grep from="'-'" to="_">s_<txp:section /></txp:pax_grep></txp:variable>
  <txp:variable name="body_class"><txp:pax_grep from="'-'" to="_">s_<txp:section /></txp:pax_grep></txp:variable>
</txp:aks_cache>
<txp:aks_cache id='otf_css_<txp:section />' noreset="1">
  <!-- On-the-fly styles for highlighting active section -->
  <style type="text/css">
    .<txp:variable name="body_id" /> #nav_<txp:variable name="body_id" /> a {
      color:#95292c;
    }
  </style>
</txp:aks_cache>

As you can see, there is nothing special, just some tags-in-tags in the id attribute.

However, as the above table shows, the cache block is created twice, one suffixed, and the other one not, and with different sizes. The difference in sizes comes from the fact the un-suffixed version is just wrong.
For example, the otf_css_news cache block renders:

<!-- On-the-fly styles for highlighting active section -->
<style type="text/css">
.s_news #nav_s_news a {
color:#95292c;
}
</style>

While the otf_css_ (wrong, un-suffixed) version renders:

<!-- On-the-fly styles for highlighting active section -->
<style type="text/css">
.s_ #nav_s_ a {
color:#95292c;
}
</style>

In the case of site_vars_news and site_vars_ the thing is worst, as it renders empty (as you can see, it only has 3 bytes).

May this be this a bug?


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#13 2010-05-06 03:58:06

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: aks_cache: Partial caching web pages. SpeedUp your site!

This is even weirder than I would have expected.
On some other place, I’m using two aks_cache blocks that are almost identical in content, and in both blocks I’m using something like this.

   <txp:aks_cache id='sectionA_<txp:article_id />'>
   <txp:aks_cache id='sectionB_<txp:article_id />'>

For sectionA, the cache blocks are created properly: sectionA_1, sectionA_2, sectionA_3, etc.

But for sectionB, the cache block is created as: sectionB_.

I can’t spot any differences (beside some different HTML/TXP tags on the inside of each aks_cache block).


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#14 2010-05-06 08:56:23

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: aks_cache: Partial caching web pages. SpeedUp your site!

maniqui wrote:

<txp:aks_cache id='site_vars_<txp:section />'>
  <txp:variable name="body_id"><txp:pax_grep from="'-'" to="_">s_<txp:section /></txp:pax_grep></txp:variable>
  <txp:variable name="body_class"><txp:pax_grep from="'-'" to="_">s_<txp:section /></txp:pax_grep></txp:variable>
</txp:aks_cache>

Hint: <txp:variable name="body_id" value="123" /> tag stores only in memory as PHP variable and this can’t be cached.

For debug, please add <txp:section /> tag in your block, same as:

<txp:aks_cache id='otf_css_<txp:section />' noreset="1">
  <!-- On-the-fly styles for highlighting active section =<txp:section />= -->
  <style type="text/css">
    .<txp:variable name="body_id" /> #nav_<txp:variable name="body_id" /> a {
      color:#95292c;
    }
  </style>
</txp:aks_cache>

What version of TxP is used? Maybe need set some section as default (admin tab Sections)?
Please run this simple test:

1=<txp:section />=1
<txp:variable name="body_id">2=<txp:section />=2</txp:variable>
<txp:variable name="body_id" />
<txp:variable name="body_id2" value='3=<txp:section />=3' />
<txp:variable name="body_id2" />
<txp:if_section name="">
4=<txp:section />=4
</txp:if_section>

My output is: 1=default=1 2=default=2 3=default=3 4=default=4
and block for “no section” created as otf_css_default


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#15 2010-05-06 09:09:41

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: aks_cache: Partial caching web pages. SpeedUp your site!

maniqui wrote:

<txp:aks_cache id='sectionB_<txp:article_id />'>

For sectionA, the cache blocks are created properly: sectionA_1, sectionA_2, sectionA_3, etc.
But for sectionB, the cache block is created as: sectionB_.

It used in individual_article or article listing?
Maybe need use it:

<txp:if_individual_article>
<txp:aks_cache id='sectionB_<txp:article_id />'>...</txp:aks_cache>
</txp:if_individual_article>

aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#16 2010-05-06 09:27:56

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: aks_cache: Partial caching web pages. SpeedUp your site!

Possible, it’s a bad practice… but your can, not set id attribute.
By default id = $_SERVER["REQUEST_URI"]

Limitation for “not set id attribute”: one unique block per page.

Maybe in next version aks_cache need add attribute block ?
for using aks_cache witout id attribute same as:

<txp:aks_cache block="block1">123</txp:aks_cache>
<txp:aks_cache block="block2">456</txp:aks_cache>

on page http://domain.com/section1/page1 this create blocks:

block1/section1/page1
block2/section1/page1

Upd: New version aks_cache 0.2.5

Changes:

  • Add attribute block

Now, all examples in this post is available. :)

Last edited by makss (2016-01-16 18:52:58)


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#17 2010-05-06 14:35:33

sereal
Member
From: Indonesia
Registered: 2010-02-18
Posts: 55

Re: aks_cache: Partial caching web pages. SpeedUp your site!

this is wonderful !


$(mydocument).notyetready(function() {});
dowebsitesneedtolookexactlythesameineverybrowser ?

Offline

#18 2010-05-06 15:15:06

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: aks_cache: Partial caching web pages. SpeedUp your site!

makss wrote:

Hint: <txp:variable name="body_id" value="123" /> tag stores only in memory as PHP variable and this can’t be cached.

Good to know.

What version of TxP is used? Maybe need set some section as default (admin tab Sections)?

4.2.0. No, on TXP you don’t have to set a “default” section. On “Sections” tab, you can define which section will be selected by default (on the Write tab dropdown menu) or you can select which template/css will use the “default” section (aka, the root domain), but there is no concept of “choose a ‘default’ section”.

Please run this simple test:
My output is: 1=default=1 2=default=2 3=default=3 4=default=4

Same output here.

and block for “no section” created as otf_css_default

Not sure what you mean here by “no section”.

Thanks.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#19 2010-05-06 15:17:06

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: aks_cache: Partial caching web pages. SpeedUp your site!

maniqui wrote:

<txp:aks_cache id='sectionB_<txp:article_id />'>

For sectionA, the cache blocks are created properly: sectionA_1, sectionA_2, sectionA_3, etc.
But for sectionB, the cache block is created as: sectionB_.

makss wrote:

It used in individual_article or article listing?

Both are being used on individual_article listing, taking the advantage that article tags like article_id are available to the template when in individual-article.

Maybe need use it:

<txp:if_individual_article>
<txp:aks_cache id='sectionB_<txp:article_id />'>...</txp:aks_cache>
</txp:if_individual_article>

Will try it that too, to see if it makes any differences.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#20 2010-05-06 15:23:13

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: aks_cache: Partial caching web pages. SpeedUp your site!

makss wrote:

Upd: New version aks_cache 0.2.5

Thanks! I’ll try it asap, and will check if the new block attribute let us also do some tags-in-tags magic with better/more-predictable behavior than when using the id attribute.

BTW, regarding the original problem, where ids like css_<txp:section /> were creating two cache_blocks (the correct css_mysection, and the incorrect css_), I’ve tested further and noticed that it doesn’t happens in every section.
In other words, there are some sections that never create the wrong css_ cache-block, while there are other sections that always triggers this bad behavior.
I haven’t been able to find out any difference (in code) that would be the cause of this different behavior.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB