We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33657
    • 128 Posts
    So i built this newsroom page, it uses get resources x 4 or 5 times, archivist, tag lister, and a snippet or two. needless to say, its taking 8 seconds to process how to load the page.

    Can someone browse over this real quick and tell me if there is a more efficient way to do it?

    i was thinking about doing a switch statement at the top? and just loading like 4 or 5 chunks (each chunk contains the whole page) or maybe there is something else?

    regardless i want to keep only 1 template, and then tell the template to change, rather than use a different template for each section.

    <!doctype html>
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
    <head>
    <meta charset="UTF-8">
    <title>[[++site_name]] - [[*pagetitle]]</title>
    <base href="[[++site_url]]" />
    </head>
    
    <body>
    <div id="top-bg"></div>
    <div id="header-pic"></div>
    <div id="header" class="container_12 clearfix">
      <header class="top"> 
        
        <!-- Logo Here --> 
        <a href="index-content.html">
        <div id="logo"></div>
        <!-- end #logo .grid_4 --> 
        </a> 
        
        <!-- Main Navigation Here -->
        <div> [[Wayfinder? &startId=`0` &outerTpl=`menuContainer` &rowTpl=`menu_row` &innerTpl=`menu_inner` &cacheResults=`1` level=`3`]] </div>
        <!-- end #top-nav .grid_8 --> 
        
      </header>
    </div>
    <!-- BEGIN CALL TO ACTION -->
    <div class="inner-cta-wrap blue">
      <div id="call-to-action" class="container_12 clearfix"> 
        
        <!-- TOP SENTENCE -->
        <div id="cta-top" class="grid_12">
          <h2 class="inner-title [[*id:gt=`48`:then=`small`]]">[[*pagetitle]][[*longtitle:notempty=`: <span class="white">[[*longtitle]]</span>`]]</h2>
        </div>
        <!-- end #cta-top .grid_6 .alpha --> 
        
      </div>
      <!-- end .container_12 #call-to-action --> 
    </div>
    <!-- end .cta-wrap -->
    
    <div class="clear"></div>
    
    <!-- Begin Main Body -->
    <div class="container_12 clearfix" id="body-wrap" role="main">
      <div id="breadcrumb-wrap">
        <div class="breadcrumb">You are here:</div>
        <div class="grid_10">[[Breadcrumbs? &crumbSeparator=`  >  `]]</div>
      </div>
    
    		
    		<!-- BEGIN SIDEBAR -->
    		<div id="sidebar" class="grid_4 suffix_1">
    		
        <!-- Begin Tabbed Content -->
        <div class="tabContainer left widget" >
          <ul class="tabbed-content">
            <li><a href="#tab1">Latest Press Releases</a></li>
            <li><a href="#tab2">Latest Events</a></li>
            <li class="last-tab"><a href="#tab3">Latest Blog</a></li>
          </ul>
          <div class="tabDesc ">
            <div id="tab1" class="tab_content"> 
              
    	  [[!getResources:default=`<h5>No Results Found</h5>`? &parents=`51` &tpl=`latestTpl` &limit=`10` &showUnpublished=`0` &showHidden=`1` &processTVs=`1` &includeTVs=`1` &includeContent=`1`]]
              
            </div>
            <!-- end .tab_content #tab2 -->
            <div id="tab2" class="tab_content ">
              	[[!getResources:default=`<h5>No Results Found</h5>`? &parents=`52` &tpl=`latestTpl` &limit=`10` &showUnpublished=`0` &showHidden=`1` &processTVs=`1` &includeTVs=`1` &includeContent=`1`]]
              <!-- end .profileList .left --> 
            </div>
            <!-- end #tab1 .tab_content -->
            
            <div id="tab3" class="tab_content"> 
              <!-- latest news posts or whatever --> 
    	[[!getResources:default=`<h5>No Results Found</h5>`? &parents=`53` &tpl=`latestTpl` &limit=`10` &showUnpublished=`0` &showHidden=`1` &processTVs=`1` &includeTVs=`1` &includeContent=`1`]]
            </div>
          </div>
          <!-- end .tabDesc --> 
          
        </div>
        <!-- end .tabContainer .left --> 
        
    				
    		
    		<div id="tags-sidebar" class="widget">
    			<h3 class="widget-title">Popular Tags</h3>
    			<p class="tags">
    [[!tagLister? &tv=`tags` &limit=`5` &target=`58`]]
    			</p>
    		</div><!-- end #tags-sidebar .widget -->
    		  <div class="clear"></div>
    		  
    		<div id="tags-sidebar" class="widget">
    			<h3 class="widget-title">
    
    			  All Newsroom Archives			  
    		  
    		  	</h3>
    			<p>[[!Archivist? &parents=`51,52,53` &target=`56`]]</p>
    		</div><!-- end #tags-sidebar .widget -->  
    		
    		</div><!-- end #sidebar .grid_4 .suffix_1 -->
    		
    		<div id="post-content-wrap" class="grid_7">
    		  
    		  [[*id:is=`48`:then=`
    		  [[!getResources:default=`<h5>No Results Found</h5>`? &parents=`51` &tpl=`newsTpl` &limit=`1` &showUnpublished=`0` &showHidden=`1` &processTVs=`1` &includeTVs=`1` &includeContent=`1`]] [[!getResources? &parents=`52` &tpl=`newsTpl` &limit=`1` &showUnpublished=`0` &showHidden=`1` &processTVs=`1` &includeTVs=`1` &includeContent=`1`]] [[!getResources? &parents=`53` &tpl=`newsTpl` &limit=`1` &showUnpublished=`0` &showHidden=`1` &processTVs=`1` &includeTVs=`1` &includeContent=`1`]]
    		  `]]
    		  
     		  [[*id:is=`51`:then=`
    		  [[!getResources:default=`<h5>No Results Found</h5>`? &parents=`51` &tpl=`newsTpl` &limit=`5` &showUnpublished=`0` &showHidden=`1` &processTVs=`1` &includeTVs=`1` &includeContent=`1`]]
    		  `]]
     		  
    		  [[*id:is=`52`:then=`
    		  [[!getResources:default=`<h5>No Results Found</h5>`? &parents=`52` &tpl=`newsTpl` &limit=`5` &showUnpublished=`0` &showHidden=`1` &processTVs=`1` &includeTVs=`1` &includeContent=`1`]]
    		  `]]
    		  
    		  [[*id:is=`53`:then=`
    		  [[!getResources:default=`<h5>No Results Found</h5>`? &parents=`53` &tpl=`newsTpl` &limit=`5` &showUnpublished=`0` &showHidden=`1` &processTVs=`1` &includeTVs=`1` &includeContent=`1`]]`]]
    
    		  
     [[*id:is=`56`:then=`
    [[!getArchives?&parents=`51,52,53`&toPlaceholder=`archives` &showHidden=`1` &tpl=`newsTpl`  &showUnpublished=`0` &processTVs=`1` &includeTVs=`1` &includeContent=`1`]]
     
    [[+archives]]
    		  `]]
    
     [[*id:is=`58`:then=`
    		  
    [[!getResourcesTag? &parents=`51,52,53` &toPlaceholder=`results`  &showHidden=`1` &tpl=`newsTpl`  &showUnpublished=`0` &processTVs=`1` &includeTVs=`1` &includeContent=`1`]]
     
    [[!+results]]		  
    		  
    		  `]]		  
    		  
    		  [[!IfNotInList?  &list=`48,51,52,53,56,58` &show=`
    
    		  
    		  
    		 <div class="blog-page-post">
    
    	<h3 class="blog-page-title"><a href="[[~[[*id]]]]">[[*pagetitle]]</a></h3>
    	
    	<div class="blog-page-meta grid_2 alpha">
    		<ul>
    			<li class="calendar">[[*publishedon:strtotime:date=`%a %b %e, %Y`]]</li>
    			<li class="cat-icon"><a class="category" href="[[~[[getResourceField? &id=`[[*parent]]` &field=`id` &default=`#`]]]]">
    [[getResourceField? &id=`[[*parent]]` &field=`pagetitle` &default=`Sorry, no data available`]]</a></li>
    		</ul>
    		
    		<div class="clear"></div>
    		<span class="blog-tags [[*mainImage:default=`shifty`]]">Tags:</span>
    			<p class="tags [[*mainImage:default=`shifty`]]">
    			  [[!tolinks? &items=`[[*tags]]`&target=`58` &outputDelim=` `]]
    			</p>
    		
    	</div> <!-- end .meta -->
    	
    	<div class="featured-image grid_5 omega" >	
    	  
    	  <img [[*mainImage:default=`class="hidden"`]]" src="[[*mainImage:default=`images/news-blank.gif`:phpthumbof=`w=380&h=165&zc=1`]]" alt="[[*pagetitle]]"/>
    	</div><!-- end .featured-image -->
    	
    	<div class="clear"></div>
    	<div class="blog-excerpt" >
    	  <!-- [[*YouTube:notempty=`<iframe src="[[*YouTube]]?wmode=transparent&rel=0&autohide=1&modestbranding=0&showinfo=0" frameborder="0" width="540" height="366"></iframe>`]] -->
    	<p>[[*content]]</p>
    	
    	</div> <!-- end #content -->
    
    <div class="hr-pattern"></div>
    	
    </div> <!-- end .blog-page-post -->
    	  
    	  		  <div class="clear"></div>
    		  
    
    		  `]]
    		  
    
    		
    		</div><!-- end #post-content-wrap .grid_7 -->
    	
    	</div> <!-- end #body-wrap .container_12 -->
    	
    	<div class="clear"></div>
    [[$footer]] 
    </body>
    </html>
    
    
      • 22303 MODX Staff
      • 10,725 Posts
      First, cache everything!

      Second, get rid of the conditional filters in your Template and make a Snippet or Template Variable that handles that logic.

      Third, consider simplifying the page.
        • 33657
        • 128 Posts
        I JUST cached all the get resources commands. still 8 seconds.

        then i cached all the tag lister and archivist commands. 1 second or less.

        probably was a combination of both...

        now the page flies.. even though its complex.

        Thanks!

        does cacheing mean that if they make a new post or change a tag things won't update? or does the cache get cleared on save in the admin tool?
          • 22303 MODX Staff
          • 10,725 Posts
          The cache gets cleared (unless you tell it not to) when making changes to Resources, Elements, System Settings, and other data in the admin interface. You should always cache everything IMO, and if something shouldn't be cached until something is changed, use getCache or other custom caching approaches to at least cache it for a period of time.