This is a fairly generalized question, maybe I completely missed where to learn about this, but I've always been curious about it as it'd help me be a little more aware of what would and would not be good practice in plugin development.
I often read the first user request is slowest to Craft Sites point mentioned in articles/posts, what exactly is that referring to?
With each page request are all plugins and their files opened and loaded up? Or are these loaded and stored somewhere for X period of time, decreasing loading time per request?
Some examples of plugin scenarios/questions
1:
I have a fairly decent-sized loop in two plugins via public function registerSiteRoutes() {}
that generate 200-1000+ custom routes, as those URL's will not have any content from Craft's entries (and thus don't have URL's,) or are completely dynamic (for forum topics with unpredictable topic urls.)
Is this loop that creates these URL's running every single time a page is requested? Is this bad practice?
2:
I can have some plugin services load large files of data in __construct()
, or as var $data;
for use in specific scenarios. Under the assumption that these service files are only loaded when a plugin calls to it, it wouldn't be slowing requests down that don't use the data because only the pages calling for them would load the data, such as through craft()->myPluginName_serviceName->getVarWithLotsOfData;
requests.
Or do these files get loaded up regardless of being called, and therefore should be re-written into functions so that they don't load the data unless asked?
3:
Plugin count -- does having many small, niche plugins affect load speed versus less but larger plugins that cover more functionality? Is plugin count something that needs to be carefully considered, a common caution when working with a plugin-based CMS like Wordpress?
--
Basically, I guess the question is, I would love to be able to read a detailed explanation of the scheme/process in how plugins and their respective plugin file, config, services, controllers, templates, variables etc are loaded, and if there is a guideline on what is and isn't good practice when designing the flow of plugins for optimization?
If there is documentation that I missed that greatly covers and explains all of this, feel free to link it and put me in a corner for shame. D:
Thanks,