1

Recently my site started to use excessive loading times on every page. After the first GET request I have this:

           "receive" : 2,
           "dns" : 15,
           "send" : 0,
           "ssl" : 100,
           "wait" : 6005,
           "blocked" : 1,
           "connect" : 142

I suspect this has to do with the SSL certificate (Let's Encrypt) as my identical subdomain http://stage.example.com does not behave like this. The waiting time is about 1 sec on the stage site.

I have this in my .htaccess file to redirect users to https:

RewriteEngine on
  RewriteCond %{HTTPS} !=on
  # This checks to make sure the connection is not already HTTPS

  RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
  # This rule will redirect users from their original location, to the same location but using HTTPS.
  # i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
  # The leading slash is made optional so that this will work either in httpd.conf
  # or .htaccess context


  # Set "protossl" to "s" if we were accessed via https://.  This is used later
  # if you enable "www." stripping or enforcement, in order to ensure that
  # you don't bounce between http and https.
  RewriteRule ^ - [E=protossl]
  RewriteCond %{HTTPS} on
  RewriteRule ^ - [E=protossl:s]

Anyone who can think of a possible reason for this loading time on my production site?

EDITED: Sorry, the redirect rule was incomplete, the code above is what I use. Also when accessing a phpinfo.php file directly in the root, there is hardly any waiting time (<50 ms).

MrWhite
  • 11,643
  • 4
  • 25
  • 40
TBJ
  • 171
  • 1
  • 8
  • Try using this redirect code:    RewriteCond %{HTTPS} !on                          RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] – Nikhil_CV May 16 '18 at 09:29
  • Nikhil_CV: I tried it with no change in the waiting time. Maybe this has nothing to do with the rewriting rule after all. – TBJ May 16 '18 at 09:53
  • @TBJ : Is this a public facing domain? If yes, could you please share the domain name? – Nikhil_CV May 16 '18 at 09:58
  • Nikhil_CV: https://www.nordtec.se, be aware though that most pages are cached in the backend with fast loading times. Also I discovered that when accessing a php file directly in the root (phpinfo), there is hardly no waiting time. – TBJ May 16 '18 at 11:24
  • 2
    If there is no waiting time with a php script that only contains phpinfo chances are high that the problem is in the php code itself, not in the server configuration. – Gerald Schneider May 16 '18 at 11:35
  • Gerald Schneider: the thing is that I have a stage subdomain with identical codebase and identical database on that same server. The loading times on that site is normal (<3 sek). The only thing that differs is that the production site is https with a Let's Encrypt certificate. – TBJ May 16 '18 at 12:23
  • TRiG: Sorry about that, the site URL is https://www.nordtec.se. The site is cached in the backend so it might appear fast on certain pages that already are visited. – TBJ May 16 '18 at 12:27
  • 1
    Is the delay when you access the HTTP site and then you are redirected? (Although you seem to have removed the redirection currently?) Or do you still see the delay when accessing HTTPS directly (ie. no redirection)? "most pages are cached in the backend with fast loading times." - if _cached_ pages are fast then that also implies there is a problem with page generation/PHP (as @Gerald suggests), since the HTTP to HTTPS redirection would still occur and you are still accessing over HTTPS. Is the "cached page" the same as a "non-cached page" - in terms of the response sent back to the client? – MrWhite May 17 '18 at 12:28
  • 1
    @TBJ : Few recommendations are that you need to optimize images, minify the scripts used, make sure all URLs hard coded are changed to https, make sure JavaScripts are rendered properly, minify the scripts, update your CMS to latest stable version of your choice. I would also suggest using CDN to help with better caching. Primarily, ask devs to optimize scripts and media, especially that are stored in external servers. – Nikhil_CV May 17 '18 at 14:50
  • MrWhite : thanks for the info. I have managed to get faster loading times now by using a 2 weeks old database backup, so it turns out it had nothing to do with the redirect (nor the php code). Still not sure what caused that extra time, will analyze in detail when there is time. Thanks again for all the input. – TBJ May 17 '18 at 14:54

0 Answers0