Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
Hi there couchies,

I've been working on a web application that helps my employer keep track of the work that's been done.

Everything works perfectly but I've noticed that the pages take really long to load. I've optimised an minimized everything using google webmaster tools but the pages are still slow. Then I proceeded to cut parts of the code and found the following part was causing the long loading times.

Code: Select all
<cms:set custom2="display=true|afgerond=actief"/>
                     <cms:pages masterpage="projecten.php" custom_field=custom2>
                        <cms:set project=k_page_title/>
                        <cms:set foto=foto 'global'/>
                        <cms:set id=k_page_id 'global'/>
                        <cms:set custom="display=true | mode=werkzaamheden |status_taak!=Voltooid|member_name=<cms:show own_member_title/>|project=<cms:show project/>"/>
                           <cms:pages masterpage='members/werkzaamheden.php' custom_field=custom>
                              <cms:if k_count='1'>
                                 <li class="large-2 medium-2 columns">
                                 <div class="project">
                                    <div class="container" style="background-image:url(<cms:show_securefile 'foto' >
                                       <cms:if file_is_image >
                                         <cms:cloak_url link=file_id />
                                          
                                       </cms:if>
                                       </cms:show_securefile>)">
                                       <h2 class="projecttitel"><a href="projecten.php?p=<cms:show id/>"><cms:show project /></a></h2>
                                    </div>
                                 </div>
                              </li>
                              </cms:if>
                           </cms:pages>
                     </cms:pages>


This is what it does:
There are some cloned pages for members, a lot of cloned pages for tasks (werkzaamheden), and some for projects (projecten).

The tasks are connected to the members and to a project, the code displays the projects that the logged in member is connected to through a task (or several tasks, but we only want to show the project once).

Currently I'm loading this part asynchronically but I'd like to know if there is a way to make this part less heavy.
Hi Saskia,

You mentioned
a lot of cloned pages for tasks (werkzaamheden) ..

Which makes the following portion of your code the most unoptimized as it loops through *all* the 'lot of cloned pages for tasks' you mentioned to display only the very first one
Code: Select all
<cms:pages masterpage='members/werkzaamheden.php' custom_field=custom>
    <cms:if k_count='1'>
        ..
    </cms:if>
</cms:pages>

You should, instead, make use of the 'limit' parameter to fetch only one page -
Code: Select all
<cms:pages masterpage='members/werkzaamheden.php' custom_field=custom limit='1'>
    ..
</cms:pages>

I think that single bit of change should make a perceptible difference.

That said, I see that you are not making use of 'relations' (atleast, none that I could spot). Your use-case is ideal for using this feature to relate the 'members', 'projects' and 'tasks'. That should really optimize the code in the best way possible.
2 posts Page 1 of 1
cron