[TYPO3-dev] better cache management in extensions (tt_news example)
Michael Stucki
michael at typo3.org
Tue Apr 1 15:01:16 CEST 2008
Hi Krystian,
can you add your suggestions to the Wiki, please? Just to avoid the
information won't get lost...
- michael
Krystian Szymukowicz wrote:
>
> hi
>
> Today typical use of tt_news extension and cache settings:
>
> root
> |-- sys folder - tt_news records (id = 2) TCEMAIN.clearCacheCmd = 3,4
> |-- standard page - tt_news LIST_VIEW (id = 3)
> |-- standard page - tt_news SINGLE VIEW (id = 4)
>
>
> With every change on sys_folder (id = 2) all cache of id 3,4 are cleared.
>
> It is not optimal.
>
> In systems with few thousand tt_news records and average 1000ms tt_news
> item rendering we have thousand seconds of server usage (3600s = 1h).
>
>
> Is seems like there is a way to clear only cache of pages that have
> changed.
>
>
> FIRST STEP
> --------------------------
> Mark every occurrence of tt_news record at page (let's call it "tt_news
> record marker"). This is simple. We can use id of the news with proper
> word.
>
> It is up to webdesigner how he will integrate it into his tt_news
> template. Few possibilities:
>
> 1) additional class in <a>
> <a href=?...? class=?designclass ttnews_cache_232?>tt news reecord 232
> title</a>
> <a href=?...? class=?designclass ttnews_cache_212?>tt news reecord 212
> title</a>
>
> 2) id in <a>
> <a href=?...? class=?designclass? id=?ttnews_cache_232?>tt news reecord
> 232 title</a>
> <a href=?...? class=?designclass? id=?ttnews_cache_212?>tt news reecord
> 212 title</a>
>
> 3) additional div
> <div id=?ttnews_cache_232?><a href=?...? class=?designclass? >tt news
> reecord 232 title</a></div>
> <div id=?ttnews_cache_232?><a href=?...? class=?designclass?
> id=?ttnews_cache_212?>tt news reecord 212 title</a></div>
>
> 4) simple html comments after record link
> <a href=?...? class=?designclass? id=?ttnews_cache_212?>tt news reecord
> 212 title</a><!-- ttnews_cache_232 -->
>
>
> SECOND STEP
> --------------------------------------
> Define what "cache_pages" to search in for "tt_news record markers".
> This id for performance issue in order not to search in all cache_pages
> records.
> This setting is similar "TCEMAIN.clearCacheCmd = 3,4" but because
> TCEMAIN.clearCacheCmd is not optimal in this scenario we have to define
> that another way: For example something like:
>
> plugin.tt_news.clearCache = 3,4
>
>
>
> THIRD STEP
> --------------------------------
> A hook "after record save" will get pids from plugin.tt_news.clearCache
> and id of tt_news that was modified and will delete from "cache_pages"
> table all records with ttnews_cache_[id] in "HTML" field of "cache_pages".
>
>
>
> Above clear cache system is good for the case the tt_news record was
> only edited.
> If we add or delete tt_news record we have to clear LIST_VIEWS anyway
> but do not have to clear cache of SINGLE_VIEW page (which we have to do
> with standard TCEMAIN.clearCacheCMD).
>
>
> To get add/delete into account the TS settings needs to be little
> expanded.
>
> Example:
>
> plugin.tt_news.clearCache.list_view_pids = 3
> plugin.tt_news.clearCache.single_view_pids = 4
>
>
> Lets see what have to be done in different tt_news record operation.
> a) RECORD EDIT
>
> For "RECORD EDIT" use "tt_news record markers" search and delete in
> plugin.tt_news.clearCache.list_view_pids
> plugin.tt_news.clearCache.single_view_pids
>
>
> b) RECORD ADD/DELETE
>
> For "add,delete" clear all page_cache for:
> plugin.tt_news.clearCache.list_view_pids
>
> AND use "tt_news record markers" for
> plugin.tt_news.clearCache.single_view_pids
>
> to search for bi-directional relation of new/deleted record.
>
>
>
>
> Take into account that in both cases we didn't have to clear all
> SINGLE_VIEW cache and in case of simple tt_news edit we delete really
> only those pages that are needed.
>
>
> Although it seems to be possible I would like to have your opinion,
> because I am not very good in TYPO3 internals and maybe there is a
> simple misunderstanding in my idea.
>
>
> --
> grtz
> Krystian
--
Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/
More information about the TYPO3-dev
mailing list