TYPO3 - Disable cache for an extension
Asked Answered
I

5

10

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.

Inhale answered 15/3, 2011 at 12:0 Comment(0)
A
2

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/

Americana answered 11/7, 2012 at 20:57 Comment(3)
As stated in the other answers - disabling cache in page properties leads to full cache disablling for that page and not only for the extension itself.Sussi
Both links are broken.Docket
See also help center: "Provide context for links Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the external resource is unreachable or goes permanently offline." stackoverflow.com/help/how-to-answerDocket
S
27

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

Sycosis answered 23/3, 2011 at 13:11 Comment(2)
Your suggestion for the ext_localconf.php file has just fixed something that's been driving me mad for aaaaages...Gutierrez
Very old and outdated answerDocket
A
2

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/

Americana answered 11/7, 2012 at 20:57 Comment(3)
As stated in the other answers - disabling cache in page properties leads to full cache disablling for that page and not only for the extension itself.Sussi
Both links are broken.Docket
See also help center: "Provide context for links Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the external resource is unreachable or goes permanently offline." stackoverflow.com/help/how-to-answerDocket
R
1

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;
Rollins answered 22/3, 2011 at 11:10 Comment(1)
this does not solve all problems, you still need to change your ext_localconf.php as described in the other answer.Allista
Q
1

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

Quiescent answered 19/4, 2019 at 12:50 Comment(0)
A
-3

Use following script for remove cache from current page.

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

Above script you can use in your controller file.

Allahabad answered 18/3, 2016 at 10:4 Comment(1)
That will disable whole page caching. Don't use it.Theologize

© 2022 - 2024 — McMap. All rights reserved.