How does caching affect the various plugins triggers?
I imagine that after a page is cached the other plugins get bypassed until the cache time resets and the page gets recreated?
It depends on which of the caching systems you're using (Joomla has three) and the components (since different components can trigger plugin events at different points of their execution path).
For example, if you're caching by using the
System - Page Cache plugin, then there are only two plugin events that will fire before a cached page is served:
One is the
onAfterInitialise() event IF the plugin is ordered so that it's before the
System - Page Cache plugin. This is because
onAfterInitialise() is the first event fired by Joomla and it's the event that
System - Page Cache uses. So you'd have to have a plugin jump in on that event and before
System - Page Cache.
The other is an event fired by the
System - Page Cache plugin itself:
onPageCacheSetCaching(). That event is used to turn off caching for specific conditions. An example of when to use this is if you wanted a plugin that makes sure the Facebook bot never gets a cached page. This event only became available in Joomla 3.8 (I believe).
As for the other two caching systems (
Page Cache - Conservative and
Page Cache - Progressive) it really depends on the component. They decide if their views can be cached and they decide what and when to trigger plugin events. Generally though (ie, for com_content and most other core Joomla components) the controller will decide whether to cache the view being requested or not and most plugin events fire in the view. In other words, their events will not fire if the page is cached.
Let's use com_content as an example (assuming a front-end non-editing load of a com_content view):
display() method's first parameter is a boolean that sets whether or not to cache the view once it's built (and whether or not to server the cached file if it exists). All (front-end non-editing) com_content event triggers (
onContentAfterDisplay) are triggered in the view files (ex: see
/views/article/view.html.php). So if the cached view is served, none of those triggers will fire (since
view.html.php is not used).
Some other component might have a plugin trigger before it does the request to retrieve the cached code though. In that situation it would continue to fire regardless of whether the view is cached or not.