Significant delay in website loading time with Cloudflare

I use Cloudflare with 2 sites: The first one is a custom PHP / HTML website and the second one is a Mediawiki based (latest version 1.37) one.

Fom the last 3 weeks of November till now I was getting a constant very slow load time for the Mediawiki website fixed at 100 seconds and I was also getting the same issue with the other website with the same 100 sec delay, but randomly, not constantly as with the other one.

Today, I changed the name servers of the Mediawiki website to the ones of the hosting company’s and the problem was resolved instantly. I kept the Cloudflare name servers for the other website and the problem continued to exist in the same manner as previously.

Afterwards I again changed the name servers of the Mediawiki website back to Cloudflare’s ones and the delay reappeared.

For some reason the Mediawiki website constantly takes 100 seconds for loading when using Cloudflare.

I had the TLS encryption set to Full (strict) for both sites. There are Let’s Encrypt certificates available for both sites on the origin server. I changed the policy to Flexible and afterwards to Full (not strict) for the Mediawiki website but the problem persists.

When I use https://www.cloudflare.com/diagnostic-center/ I get an “slow_ttfb_on_cache” error.

Any idea which setting is causing this major delay to the websites’ loading time?

May I just add a note here in terms of the SSL, rather it should be Full (Strict) (as your first setting):

Are the options like Minify (HTML, CSS, JavaScript), Brotli, HTTP/2, Rocket Loader and similar enabled in the Cloudflare dashboard?

In terms of the PHP, may I suggest to tune-up a bit if possible:

memory_limit = 256M
max_execution_time = 300
max_input_time = 1000
max_input_vars = 5000 or 7000
post_max_size = 16M
upload_max_filesize = 16M

Also, if you can install the PHP OPcache module as it could help too :wink:

Do not forget to save and restart your php service to apply the changes.

Have you tried clearing your Web browser cache?, or Purging the Cache at Cloudflare dashboard? Does anything change?

Is your Website hosted on a shared web hosting or a VPS, or rather a dedicated server?

May I ask what is your domain name?

@fritex

I changed the TLS policy just for testing purposes, only for the troubleshooting procedure. I intend to change it back to Full (strict). Anyway, it did not make any difference.

The problem is not browser related either. I can reproduce it when using online website speed test tools. I get exactly always the same delay, around 100 seconds.

I use shared hosting, but for over a year everything used to work flawlessly. The problem appeared 3 weeks ago.

You can check the domain driverspedia.org.

May I ask, are you using PHP file to load CSS and JS files?
What is the .php script doing with them? Combining, compressing and minifying on each request?

I cannot properly load CSS, neither JS.

Also, you are using the same load.php in your CSS file to get or generate an image?
load.php?modules=oojs-ui-core.icons&image=error&variant=invert&format=rasterized&skin=timeless&version=1yt6z

This seems to be a lot of work for PHP on a shared (limited) hosting (MB per PHP process).

Have you tried running the app on localhost or some other hosting provider?

I think it’s better to start troubleshooting with the Mediawiki website. The problem is constant with it.

The problem happens randomly to my custom website, so troubleshooting will be more challenging with it, as it’s not always reproducible.

No. The origin server is no the issue! When I stop using the Cloudflare name servers the problem goes away.

Is Cloudflare allowed to connect to your origin host / server, or rather something in between could block it, like Firewall, etc.? See here:

Nevertheless, Cloudflare IP addresses list can be found here:

I doubt Cloudflare could cause that long TTFB issue, at least not in case if something is happening on the network (should we check on cloudflarestatus.com?).

So, what happens when you are using Cloudflare nameservers, but if you temporary switch from :orange: to :grey: (DNS-only), or rather temporary enable the option Pause Cloudflare for this site?

I don’t think anything blocks it. The origin server also supports Railgun and I have activated.
I just enabled Development mode and the website loads OK!

The website seems to continue loading fast even after disabling Development mode now. So I’m not sure if Development mode really had an effect.

Intersting, now either I finally see it.

I may not be sure, but maybe something with the default file extension (Cache Level: Standard) could be, but hm…

EDIT: No, the same thing again as soon as I get my Developer Console with “disable cache”.

The website loads fast now with Developer mode disabled. Does the same happen for you?

OK. Something weird and interesting at the same time.

I enabled developer mode for my other website too which was randomly was having the same issue. The problem vanished from it too and the improvement continues after disabling the Development mode again.

Since enabling the Developer mode and re-disabling it after numerous tries via my browser or with online tools I didn’t get a delay even once.

I still find it weird to load the stuff via PHP file, and it takes some time to.

Neverthless, now it loads okay at my end.

Also I noticed the Railgun usage:

  • cf-railgun: f59616de29 stream 0.000000 0200 57da

What do you mean weird? It’s how the Mediawiki is implemented.

Anyway, after switching “Developer mode” on for both sites the problem got resolved for both of them and it remained resolved after deactivating it again.

Somehow activating developer mode solved the issue. A cache problem maybe?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.