Dali
Dali

Reputation: 7882

TYPO3 - Disable cache for an extension

I am a beginner in TYPO3. I have done an extension with Kickstarter and I want to disable cache only for this extension, and not for the other pages of my TYPO3 website.

How can I do that?

Thanks a lot.

Upvotes: 10

Views: 17682

Answers (5)

ebricca
ebricca

Reputation: 386

Also to disable or limit the caching time on a per page basis might be a solution The setting is under pageicon edit -> tab behaviour -> cache settings (the ?no_cache=1 url parameter)

Another way would be to clear the cache when the data was changed in a sysfolder / set an autoclear in its ts page config for single pages TCEMAIN.clearCacheCmd = 1,3,5 -- numbers are pid comma seperated TCEMAIN.clearCacheCmd = all -- or clear cache all

context links on the archive.org wayback machine - mind all of this is very old - for typo3 v4.5 .. tough i guess some are even now still running ..

http://web.archive.org/web/20180128154846/http://typo3blog.at/blog/artikel/typo3-caching-grundlagen/

http://web.archive.org/web/20150420070446/http://typo3weblog.de/2008/07/26/tcemainclearcachecmd-statt-clear-cache-button/

Upvotes: 2

ESP32
ESP32

Reputation: 8709

Unfortunately these answers are more than 8 years old. Nowadays the ExtensionUtility class supplies a switch for disabling caching based on actions:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'MyCompany.' . $_EXTKEY,
    'Sample',
    ['Sample' => 'index'],
    // non-cacheable actions:
    ['Sample' => 'index']
);

https://docs.typo3.org/typo3cms/ExtbaseFluidBook/4-FirstExtension/7-configuring-the-plugin.html

Upvotes: 1

Jainish
Jainish

Reputation: 149

Use following script for remove cache from current page.

$GLOBALS['TSFE']->set_no_cache() 

Above script you can use in your controller file.

Upvotes: -3

user673046
user673046

Reputation:

you need to pay attention to three locations. First have a look at your ext_localconf.php file. For each plugin (by plugin i mean Frontend Plugin) there is a line similar to this one:

t3lib_extMgm::addPItoST43($_EXTKEY, 'pi1/class.tx_yourext_pi1.php', '_pi1', 'list_type', 1);

To disable the cache you need to set the last value to zero, like this.

t3lib_extMgm::addPItoST43($_EXTKEY, 'pi1/class.tx_yourext_pi1.php', '_pi1', 'list_type', 0);

Within the Plugin's PHP file (e.g. pi1/class.tx_yourext_pi1.php) you need to ensure that the following line is either deleted, commented out or changed to "false"

$pi_checkCHash = true;

At last, add this line to your main() function (somewhere below the rest):

$this->pi_USER_INT_obj = 1;

That should do it.

cu Roman

Upvotes: 27

jensgram
jensgram

Reputation: 31508

Using $GLOBALS['TSFE']->set_no_cache() will disable caching for the entire page!

Call the function $GLOBALS["TSFE"]->set_no_cache(), if you want to disable caching of the page. Call this during development! And call it, if the content you create may not be cached.

Other sources are explanatory.

Instead, make sure that your extension is of type USER_INT, cf. the docs.

$this->pi_USER_INT_obj = 1;

Upvotes: 1

Related Questions