[TYPO3-dev] Fight the no_cache parameter

JoH asenau info at cybercraft.de
Tue Apr 17 00:04:01 CEST 2007


>> As far as I can see this is not the case, since the switch
>> pageCacheToExternalFiles only decides where to put the cached
>> content. The handling of the stuff remains exactly the same, so the
>> replacement of USER_INT still should happen as usual after reading
>> the cached file.
>
> Exactly, that's why I am talking about that the ext has to be
> USER_INT. So when rendering page, Typo3 calls ext every time and ext
> decides whether to display cached content (search form) or not cached
> (search results).

This is not the scenario you described. and BTW:
Whenever you display any kind of search results you usually still show the
search form on the same page, so that the user can fill in new stuff to
search for.

> So the ext is USER_INT, and somehow from PHP it should decide "cache
> my content" or "don't cache my content".

When you execute PHP code based on USER_INT there are no options left, since
you already _are_ outside any cached content.
And to get away from the searchform scenario which is just one example of a
mixed output imagine a shop which is a bit more complex:

Usually you will need
Searchform => Cached (or non cached if you want to autofill stuff from the
last search)
Search Results => Non Cached
Single Views of items => Cached (+Hash to get different versions based on
parameters)
A Basket => Definitely Non Cached

This all can be done within one single USER element containing a COA or a
CASE with USER and USER_INT as subelements.
And the decision if something should be cached or not is always based on the
type of the element and not on the situation.
A basket will never be cached while a single view can always be (if you
provide a correct CHash parameter)

temp.shop = USER
temp.shop {
    userFunc = myShop->main
    renderObj = CASE
    renderObj {
        key.field = select_box_field_here
        default = TEXT
        default.value = You must select a plugin function first
        searchform = USER
        searchform {
            userFunc = myShop->searchform
            renderObj = COA
            renderObj {
                ### SOME TS HERE ###
            }
        }
        searchresults = USER_INT
        searchresults {
            userFunc = myShop->searchresults
            renderObj = COA
            renderObj {
                ### SOME TS HERE ###
            }
        }
        singleview = USER
        singleview {
            userFunc = myShop->singleview
            renderObj = COA
            renderObj {
                ### SOME TS HERE ###
            }
        }
        basket = USER_INT
        basket {
            userFunc = myShop->basket
            renderObj = COA
            renderObj {
                ### SOME TS HERE ###
            }
        }
    }
}

You could even break down the basket to smaller chunks based on other TS
elements and USER_INT, while the main basket function would still be USER.

        basket = USER
        basket {
            userFunc = myShop->basket
            renderObj = COA
            renderObj {
                10 = TEXT
                10.wrap = <h1>Basket Header</h1>
                20 = TEXT
                20.wrap = <p>Some Into Text</p>
                30 = USER_INT
                30.userFunc = myShop->orderedItems
                40 = TEXT
                40.wrap = <strong>The value of all items currently in your
basket is:</strong>
                50 = USER_INT
                50.userFunc = myShop->overallSum
            }
        }

The main advantage is, that you can fine tune the caching of your plugin(s)
by breaking it down to the lowest level instead of just not caching the
whole plugin.

BTW: I would like to discuss this approach at the T3DD07 in Dietikon. Are
there any talks or tutorials planned?

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
openBC/Xing: http://www.cybercraft.de
T3 cookbook: http://www.typo3experts.com






More information about the TYPO3-dev mailing list