开发者

TYPO3 - Disable cache for an extension

开发者 https://www.devze.com 2023-02-17 09:54 出处:网络
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 p开发者_高级运维ages of my TYPO3 website.

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 p开发者_高级运维ages of my TYPO3 website.

How can I do that?

Thanks a lot.


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


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

http://typo3blog.at/blog/artikel/typo3-caching-grundlagen/

http://typo3weblog.de/2008/07/26/tcemainclearcachecmd-statt-clear-cache-button/


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;


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


Let's update this question with more recent info that applies to TYPO3 CMS 6.0.x-6.2.x at the time of this writing. If you have a dev site that's not live yet, I'd used the uncache extension made by the FluidTYPO3 team. It's nice to be able to just disable cache entirely until you get the bugs worked out so you're not clearing cache every 2 seconds.

  • uncache at TER (TYPO3 Extension Repository)
  • uncache at GitHub


Use following script for remove cache from current page.

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

Above script you can use in your controller file.

0

精彩评论

暂无评论...
验证码 换一张
取 消