DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

EXT: Easy Cache Tags

Author:Christopher
Created:2010-12-18T19:57:23
Changed:2011-09-15T12:44:18
Classification:lilio_cachetags
Description:The keywords help with categorizing and tagging of the manuals. You can combine two or more keywords and add additional keywords yourself. Please use at least one keyword from both lists. If your manual is NOT in english, see next tab "language" ---- forEditors (use this for editors / german "Redakteure") forAdmins (use this for Administrators) forDevelopers (use this for Developers) forBeginners (manuals covering TYPO3 basics) forIntermediates (manuals going into more depth) forAdvanced (covering the most advanced TYPO3 topics) see more: http://wiki.typo3.org/doc_template#tags ----
Keywords:typoscript, cache, forAdmins, forIntermediates
Author:Mathias Bolt Lesniak, LiliO
Email:mathias@lilio.com
Language:en

img-1 img-2 EXT: Easy Cache Tags

Extension Key: lilio_cachetags

Language: en

Version: 0.0.1

Keywords: typoscript, cache, forAdmins, forIntermediates

Copyright 2006-2011, Mathias Bolt Lesniak, LiliO, < mathias@lilio.com >

Sponsored by:

LiliO – www.lilio.com

This document is published under the Open Content License

available from http://www.opencontent.org/opl.shtml

The content of this document is related to TYPO3

- a GNU/GPL CMS/Framework available from www.typo3.org

Table of Contents

`EXT: Easy Cache Tags 1 <#1.EXT:%20Easy%20Cache%20Tags|outline>`_

`Introduction 3 <#1.1.Introduction|outline>`_

What does it do? 3

Why is it needed? 3

Requirements 3

Supported extensions 3

Sponsoring 4

`Users manual 5 <#1.2.Users%20manual|outline>`_

Adding Cache Tags 5

Clearing Cache 5

`Known problems 6 <#1.3.Known%20problems|outline>`_

`To-Do list 7 <#1.4.To-Do%20list|outline>`_

`Change Log 8 <#1.5.Change%20Log|outline>`_

Introduction

What does it do?

This extension introduces two new cObjects in TypoScript: CACHETAGS and CLEARCACHETAGS . These can be used to add tags to page caches, and then clear the cache for pages related to one or more cache tags.

The simplest use of this extension involves only two lines of TypoScript!

Why is it needed?

Extensions like tt_news generate different content on the same page, depending on the parameters in the URL. The somewhat cryptic cHash parameter is used to tell TYPO3 to cache a different version of the page for each unique combination of parameters. If you have 1000 news articles viewed on the same page, you'll have 1000 different cached versions of that page. When you edit an article, you'll have to clear the cache for all 1000 news articles.

Cache Tags (a feature of the Caching Framework within TYPO3) enables you to connect custom tags to each cached instance of a page. For example, the cache tag for news article UID #261 could be “tt_news_261”. It is possible to ask the Caching Framework to clear cache for only those cached instances relating to that particular tag. The result is that you clear one single cache instance instead of 1000.

You can also add multiple different cache tags to the same page.

Example: Imagine you have a site with a lot of FE Users. The users can edit their profiles through a form. You use the users' information on many different pages and in many different ways (e.g. single profile view, a list of users belonging to a specific group, etc.).

With Easy Cache Tags you can relate the tag fe_user_101 to each cache instance where FE User #101's information is rendered, and fe_user_203 to each cache instance where FE User #203 is rendered.

When FE User 203 updates his profile, you can clear cache on each cache instance related to that specific user. No other cache instances are cleared, and you don't even need to think about which Page ID's to clear!

Requirements

This extension requires that you have the new Caching Framework enabled in TYPO3.

In TYPO3 version 4.5 and below you must enable the caching framework in localconf.php. Here's how you do it:

$TYPO3_CONF_VARS['SYS']['useCachingFramework'] = true;

You can read more about the Caching Framework at wiki.typo3.org/Caching_framework .

Supported extensions

Easy Cache Tags can be integrated with other extensions.

Static File Cache (nc_staticfilecache)

Static files will be removed according to related Cache Tags.

Sponsoring

It is possible to sponsor new features. Please make contact at mathias@lilio.com for more information. Implementation of sponsored features is of course prioritized.

Users manual

Adding Cache Tags

You can add any number of tags each time a page is rendered. Since everything you need to do is to insert a TypoScript cObject, you can even insert it into any stdWrap property (e.g. using the prepend or append properties of stdWrap).

The CACHETAGS cObject is an array of tag names (e.g. “fe_user”). Each tag name is a normal stdWrap. The result of the stdWrap becomes the tag's value, in the format <tag name>_<tag_value>.

If the tag relates to a row uid of a specific table, we recommend that you use that table's name (e.g. “tx_myextension_records” as the tag name).

Example 1

This will create the tag “fe_user_X” (where X is the value of the someUserId parameter):

page.20 = CACHETAGS
page.20 {
  fe_user.data = GP:someUserUid
}
Example 2

Within a stdWrap (creates the tag “tx_someextension_X”, where X is whatever UID field data the extension provides):

plugin.tx_someextension_pi1.headerWrap {
  prepend = CACHETAGS
  prepend.tx_someextension.field = uid
}

Clearing Cache

Clearing cache is just as simple as adding the cache tags.

Important: The cache clearing needs to be done as non-cached content, placed within a COA_INT or rendered by a non-caching extension or on a non-cahced page.

Example 1

This will clear the cache for the the tag “fe_user_X” (where X is the value of the someUserId parameter):

page.20 = COA_INT
page.20.1 = CLEARCACHETAGS
page.20.1 {
  fe_user.data = GP:someUserUid
}
Example 2

Within a stdWrap (creates the tag “tx_someextension_X”, where X is whatever UID field data the extension provides). The clearing occurs only when the GET/POST parameter “submitted” is true (e.g. if a form is submitted, which changes data):

[globalVar: GP:submitted > 0]
plugin.tx_someextension_pi1.headerWrap {
  prepend = CLEARCACHETAGS
  prepend.tx_someextension.field = uid
}
[global]

Known problems

None known.

Please report any issues to mathias@lilio.com .

To-Do list

  • Possibility to add and clear cache based on Cache Tags in Backend.
  • Built-in support for more caching extensions.

Change Log

0.0.1

Version

0.0.1

Changes

First upload.