[TYPO3-mvc] Cached plugin with partially uncached content

Stephan Schuler Stephan.Schuler at netlogix.de
Tue Jul 1 14:25:51 CEST 2014


Hey there.


I just read through Helmuts blog post. It's straight to the point: The actual way to go when doing any "out of bound rendering" (well, I never called it that way, but I guess it's exactly what happens) really depends on the complexity of your task and the amount of API and core/framework you need.

The provided extension looks quite awesome.

The only bad thing about it: It doesn't really fit the task here.
Well, but there's a reason for it. It's a conceptual thing, and the actual task can't be solved with any current TYPO3 mechanisms. At least not without breaking lots of internal mechanisms completely.

The task, as I understand it, would be:
> Is there something like a "noCacheViewHelper" that can be used inside of a fluid template to make a tiny part of my plugins output uncached.

And the answer is: No. No way.

The way to go would be: Draw placeholders inside your output and replace them.

But the downside about that is: This isn't just "a fragment of the output". It's always a completely different request. Usually you would call it a "subRequest". But that's nothing we really have in TYPO3 environments. So it really is a completely different request.

The way to go -- and that's what Helmut pointed out -- would be to completely move the rating mechanism out of the current thing.
Don't make the "showDomainSomethingAction" do "showRating" inline and use "updateRating" as an ajax, but move both, showRatingAction and updateRatingAction and make it a completely new request. That's the only way to really separate the cached "showDomainSomethingAction", the cached "showRatingAction" (which gets cleared more often than the output of "showDomainSomethingAction") and the uncached "updateRatingAction".


There is one reason for not adding any no-cached content at all to the output: Performance.

If there is only cached content on a page, TYPO3 skips booting lots of internal things and just puts cached content out. That's fast. At least as fast as it can be. There is always the impact of deciding if there is no-cached content. But as soon as TYPO3 knows there isn't no-cached content, nearly every rendering can be stopped.

And the next thing about performance and no-cached things: They can be cached "at least a bit". That's where cache tags are important.
Think about your showRatingAction. There is no need to flush e.g. a "NewsController::showAction()" just because there is a "+1, like it" to that news.
And there is no need to flush every rating result, just because there is a "tx_news_domain_model_news_5, +1, like it". Better flush only the rating result content for tx_news_domain_model_news_5 only.
So even your "showRatingAction" can be cached. They definitively get flushed more often than your showDomainSomethingAction results. So not using uncached plugins but cached ones and proper cache tags gives you’re a huge performance boost.


One thing about cache tags: They are awesome. Use them. But use them properly.

The TYPO3 backend (TCEmain, however it is called in 6.x) triggers cache flushing of "$tableName_$recordUid". So you should really stick to those.
The showRatingAction($rateable) should tag its cached output with "tx_you_domain_model_rateable_$rateable".
The updateRatingAction($rateable) should flush caches for "tx_you_domain_model_rateable_$rateable".

Of course you are free to use whatever string tag looks nice to you. But I would strongly recommend to stick to whatever TYPO3 does internally.


Chris pointed to the caching framework and use an output cache. You definitively can do that. If you use an additional plugin for showRatingAction and initialize it with Helmuts extension, that should be harmless. But if you use e.g. eID for ajax things and miss some bootstrap initialization steps, chances are that your ajax request creates different cache results than your non-ajax request creates. Think about config.linkVars, default L param or something. If you use a shared cache between eID and non-eID, you really need to test your results carefully. That's a great source for regression and unexpected results.


Regards,



Stephan Schuler
Web-Entwickler

Telefon: +49 (911) 539909 - 0
E-Mail: Stephan.Schuler at netlogix.de
Website: media.netlogix.de



------------------------------------



--
netlogix GmbH & Co. KG
IT-Services | IT-Training | Media
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: info at netlogix.de | Internet: http://www.netlogix.de

netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Stefan Buchta, Matthias Schmidt



-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Chris Wolff - AERTiCKET AG
Gesendet: Dienstag, 1. Juli 2014 11:07
An: TYPO3 v4 MVC project
Betreff: Re: [TYPO3-mvc] Cached plugin with partially uncached content

You Might Leverage the Power of the Cachingframework.
And render your Plugin content in a cached Section.
On Rating update you simply clear the cache section.

The Cache identifier coud be something like:
YourExtension_yourOPbject_objectUID

Eg:
YourExtension_yourOPbject_123

And if your update the rating for the Object with the Uid 123.
Your simply clear the cache of the given opject. (which would invalidate all caches containing this Object as well)

As I My Self have not used the Caching framework jet. There might might be hurdles im unaware. But in theorie this sounds like the right way to go.

Regards chris


-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Jan Kornblum
Gesendet: Samstag, 28. Juni 2014 23:53
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: [TYPO3-mvc] Cached plugin with partially uncached content

Hi newgroup,

i've got a frontend plugin with a cached "showAction". This plugin / action should be extended to additionally show something like a rating.
Updating the rating itself will be done by ajax.

Now i could convert the "showAction" to be uncached - which i would like to prevent...

Another idea might be to clear the FE cache for the plugins page each time the rating is updated. Doesn't sound good to me, too...

How would you realize this?

Kind regards, Jan


_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc

_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


More information about the TYPO3-project-typo3v4mvc mailing list