I remember seeing somewhere a reference to large number of chunks in a site and possible performance related problems due to the large number. Forgive me but I do not remember now where I ran across that (here or otherwise) I am getting close to finishing my first site using modx and the way it turned out I have many chunks, currently approximately 50 and growing still. I do have some cases where I can combine, but I was wondering if there is any knowledge about the number of chunks on a site and any issues with a large number. From what I remember, and it was some time since I saw the reference, it had to do with loading up all of them even if a page did not use one.
Any thoughts are appreciated.
Craig
-
☆ A M B ☆
- 24,524 Posts
Chunks are stored in the siteCache.idx.php file, and get loaded into an array at every page load. So are snippets, as well as three different arrays representing the document/alias relationships. So that file, and the arrays, can get quite large and cause performance issues.
I tend to use TVs a lot instead of chunks; they aren’t stored in the cache file. Give them a default value, assign them to a document group that only your admin user belongs to, and they are as "hidden" as chunks are to most of your manager users.
Many of the major snippets allow the use of an external config file, where their mini-templates can be defined instead of using chunks, and some allow the use of external template files as well.
I use alot of template variables myself, but I do have a bunch of chunks as well. I haven’t noticed any slow down or performance issues, but I didn’t know they could cause problems. I have about 60 of em. I think I’m only using about 40 though (need to clean that up).
What do you mean by giving the template variable a default value? Like, it’ll have that same value across multiple pages? How do you do that?
Hi Susan,
Are you saying that if I had a site that uses say 30 chunks that I’d get a better performance if i’d used 30 TVs with the default value of the html within the chunks.
Thanks
Ben
-
☆ A M B ☆
- 209 Posts
Hi Ben,
If they’re large chunks then you may notice a performance difference, but 30 isn’t many chunks. For most sites which aren’t under a heavy load, moving chunks to TVs is a form of premature optimisation, and I’d suggest some benchmarks to see where any slowdown comes from. My guess is that compressing CSS & JS (if not done already) would provide a greater performance gain to your users than this.