2

Recently I’ve build a site with protected area. The template of this area is a single file that first check if a visitor in logged or not and that show entry basing on url segments (use a lot of if_segment tag). The entries that is showing is only one and contains a very big Matrix field with images ad some other columns. The site has installed Trascribe too.

Every time this page is request it take about 16 sec to be ready… I haven’t any idea of the cause!

Can someone help me?

Debugging the page EE tells me:

Loading Time: Base Classes   0.0143
Controller Execution Time ( Ee / Index )   19.0798
Total Execution Time   19.0944

(0.319188 / 16.42MB) Calling Extension Class/Method: Transcribe_ext/transcribe_matrix_data_query
(5.559691 / 16.95MB) Calling Extension Class/Method: Transcribe_ext/transcribe_matrix_data_query 
2
  • 1
    Can you post how many queries are on a single page? Also, install the EE Debug Toolbar to find loads of hidden issues. This add-on is killer for this stuff. You are just doing to have to do some caching and process of elimination to figure out where your bottlneck is. It may be the db, because your memory usages seems find. devot-ee.com/add-ons/ee-debug-toolbar Sep 11 '13 at 12:36
  • Please, add some samples of the code, specially the "if" parts. Is the data of this page related to the user or all logged users should see the same page for every URL?
    – Sobral
    Sep 11 '13 at 13:15
2

If you have a lot of if segment == or just a lot of ifs in general, depending on what is within your ifs this can slow your site down. If you have a lot of channel:entries calls within each if, for example. EE actually parses all the info within the ifs regardless of whether they are valid or not. This can mean your entire page is parsing. So if it's long that's a lot, especially if it has a lot of embeds.

I would look into the switchee plugin. It is more powerful in its comparisons (you can use regex) but most importantly it processes the conditionals first and then only parses those ee tags that are within the matched conditionals.

Example URL domain.com/some-url-title

{if segment_1 != ''}
  {exp:channel:entries parameters etc}
    This will all get parsed because the conditional is true
  {/exp:channel:entries}
{/if}
{if segment_1 != 'foo'}
  {exp:channel:entries parameters etc}
    This will also get parsed because of the way ee handles conditionals
  {/exp:channel:entries}
{/if}

with switchee

{exp:switchee variable="{segment_1}" parse="inward"}
  {case default="yes"}
    {exp:channel:entries parameters etc}
      This will get parsed because the conditional is true
    {/exp:channel:entries}
  {/case}
  {case value='foo'}
    {exp:channel:entries parameters etc}
      This will not be parsed because the switchee case is not true saving valuable time
    {/exp:channel:entries}    
  {/case}
{/exp:switchee}

Also simple conditionals are processed differently and take less time than complex conditionals such as if:else.

-1

Best solution ever worked is CE-Cache! Also, try to adjust your .htaccess file with:

    DirectoryIndex index.php
    AddDefaultCharset UTF-8

<IfModule mod_rewrite.c>


     Options +FollowSymLinks
        RewriteEngine on
        #RewriteBase /subdirectory/

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_URI} !^/(media)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule (.*) /index.php?/$1 [L]
</IfModule>
<IfModule mod_rewrite.c>

    #------------------- remove trailing slash -------------------
    RewriteCond %{REQUEST_URI} !^/system [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+)/$ /$1 [R=301,L,QSA]

    #------------------- index.php -------------------
    #strip index.php from the URL if that is all that is given
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
    RewriteRule ^(([^/]+/)*)index\.php$ http://%{HTTP_HOST}/ [R=301,NS,L,QSA]
    #strip index.php/* from the URL
    RewriteCond %{THE_REQUEST} ^[^/]*/index\.php/ [NC]
    RewriteRule ^index\.php/(.+) http://%{HTTP_HOST}/$1 [R=301,L,QSA]
    #------DESABLE if not USING CE-CACHE------
    #------------------- CE Cache Static Driver -------------------
    RewriteCond %{REQUEST_URI} !^/system [NC]
    RewriteCond %{QUERY_STRING} !ACT|URL [NC]
    RewriteCond %{REQUEST_METHOD} !=POST [NC]
    RewriteCond %{DOCUMENT_ROOT}/static/ce_cache/08e5d9/static%{REQUEST_URI}/index\.html -f [NC]
    RewriteRule (.*) /_static_cache_handler.php%{REQUEST_URI}/index\.html [L,QSA]

    #------------------- EE -------------------
    #rewrite all non-image/js/css urls back to index.php if they are not files or directories
    RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
</IfModule>
<IfModule mod_php5.c>
    php_value memory_limit 128M
    php_value max_execution_time 10000
    php_flag magic_quotes_gpc off
</IfModule>

<IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>

<IfModule mod_ssl.c>
    SSLOptions StdEnvVars
</IfModule>

<IfModule mod_expires.c>
    ExpiresDefault "access plus 1 year"
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 10 days"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType text/plain "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:
<files *.html>
SetOutputFilter DEFLATE
</files>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

Uninstall modules you don't use!!!!

Without CE-Cache your pages should fly!

Check this out: Recent Project(still in development) At the bottom you will see loading time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.