Jason
Jason

Reputation: 433

Long waiting time on WordPress website

I have been having an issue with a custom theme I have build for WordPress. The waiting time on the site is around 20sec+.

I tried the following without success:

Anyone knows what could be the issue? I know that waiting time in Firebug means waiting for the server response but can't figure out the problem.

Firebug showing long waiting time for page request

Upvotes: 1

Views: 2066

Answers (2)

user6272914
user6272914

Reputation:

You should apply these certain rules to have some luck:

  1. Use the W3 Total Cache plugin (it's the best in its niche) or any other cache plugin.
  2. Use optimized images if your theme has some.
  3. Compress all your CSS and JavaScript files.
  4. Use a lazy load plugin to load text quickly but images in background.
  5. Make sure you are not using any framework which slows down page load time in most cases.
  6. Use a content delivery network (CDN).
  7. Add an Expires header to static resources.
  8. Use static HTML where possible as it loads fast.
  9. Make sure there is no unnecessary extra code or files in your theme.
  10. Apply all these mentioned steps and further read about page optimization techniques to have good and long term results.

Upvotes: 2

CodyA
CodyA

Reputation: 429

Sounds like it is a PHP issue. have you tried bypassing PHP to see if that is in fact the issue? To test this, I would recommend installing a caching plugin like Cache Enabler and then implementing the advanced snippet on your origin server to bypass PHP when retrieving the cached HTML that was generated by the plugin.

Advanced snippet for Apache:

# Start Cache Enabler
<IfModule mod_rewrite.c>
 RewriteEngine On

 <IfModule mod_mime.c>
 # webp HTML file
 RewriteCond %{REQUEST_URI} /$
 RewriteCond %{REQUEST_URI} !^/wp-admin/.*
 RewriteCond %{REQUEST_METHOD} !=POST
 RewriteCond %{QUERY_STRING} =""
 RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_
 RewriteCond %{HTTP:Accept-Encoding} gzip
 RewriteCond %{HTTP:Accept} image/webp
 RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/cache-enabler/%{HTTP_HOST}%{REQUEST_URI}index-webp.html.gz -f
 RewriteRule ^(.*) /wp-content/cache/cache-enabler/%{HTTP_HOST}%{REQUEST_URI}index-webp.html.gz [L]

 # gzip HTML file
 RewriteCond %{REQUEST_URI} /$
 RewriteCond %{REQUEST_URI} !^/wp-admin/.*
 RewriteCond %{REQUEST_METHOD} !=POST
 RewriteCond %{QUERY_STRING} =""
 RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_
 RewriteCond %{HTTP:Accept-Encoding} gzip
 RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/cache-enabler/%{HTTP_HOST}%{REQUEST_URI}index.html.gz -f
 RewriteRule ^(.*) /wp-content/cache/cache-enabler/%{HTTP_HOST}%{REQUEST_URI}index.html.gz [L]

 AddType text/html .gz
 AddEncoding gzip .gz
 </IfModule>

 # default HTML file
 RewriteCond %{REQUEST_URI} /$
 RewriteCond %{REQUEST_URI} !^/wp-admin/.*
 RewriteCond %{REQUEST_METHOD} !=POST
 RewriteCond %{QUERY_STRING} =""
 RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_
 RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/cache-enabler/%{HTTP_HOST}%{REQUEST_URI}index.html -f
 RewriteRule ^(.*) /wp-content/cache/cache-enabler/%{HTTP_HOST}%{REQUEST_URI}index.html [L]
</IfModule>
# End Cache Enabler

Nginx:

server {

    set $cache_uri $request_uri;

    # bypass cache if POST requests or URLs with a query string
    if ($request_method = POST) {
        set $cache_uri 'nullcache';
    }
    if ($query_string != "") {
        set $cache_uri 'nullcache';
    }

    # bypass cache if URLs containing the following strings
    if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
        set $cache_uri 'nullcache';
    }

    # bypass cache if the cookies containing the following strings
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
        set $cache_uri 'nullcache';
    }

    # custom sub directory e.g. /blog
    set $custom_subdir '';

    # default html file
    set $cache_enabler_uri '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}index.html';

    # webp html file
    if ($http_accept ~* "image/webp") {
        set $cache_enabler_uri '${custom_subdir}/wp-content/cache/cache-enabler/${http_host}${cache_uri}index-webp.html';
    }

    location / {
        gzip_static on; # this directive is not required but recommended
        try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;
    }

    ...

}

Upvotes: 2

Related Questions