First load very slow - up to 10 Seconds

Hey, I have a problem with a small website in concrete5 8.1 When I hit the page for the first time, it takes up to 8-10 Seconds. After that it loads very fast, also in other browsers. After about 2 hours it is slow again for the first load. Cache is activated.

For debugging I turned on the database protocol.

Do you have ideas why the first load can be so slow?

Thank you

View Replies:
Gondwana replied on at Permalink Reply
Probably the c5 cached copy of the page isn't created until its first access. By default, pages in c5's cache expire after some period (although I think it's 6 hours).

These days, there could be a lot of other intermediate caches involved, including CDN (eg, Cloudflare).
dercin replied on at Permalink Reply 1 Attachment

I think the c5 cache is not the reason for the slow version because after deleting the cache in c5 the loading time of the page still fast enough, with open dev tools and browser cache disabled.

I have attached a little screenshot from dev tools when it took a very long time....
mesuva replied on at Permalink Reply
I've noticed this with 8.1 on one of our resellers servers.

I've found on one server that if a site hasn't been accessed for some time, it can take many seconds to initially load - then after that it's really fast to change pages. This is with caching off, and caching on doesn't appear to impact this initial site load.

The exception with this server is that I believe it's still running spinning hard disks, while the other reseller accounts we have are running SSDs. On the SSD servers there's really no noticeable initial slowdown.

My guess then is that the server is taking a long time to physically read and load into memory concrete5's core files, basically parse the PHP. Once it's loaded up into memory I think it's cached (PHP wise) so it doesn't have to read from the server's hard disk on every page load.

This is just a theory. I've tried a few experiments like setting up a cron job to hit the server every few minutes, sort of like a rough 'keep-alive'. This actually appears to work, but it doesn't feel like an appropriate solution.

So my suggestion would be to review your hosting - is it perhaps just slow with disk reads?

I recall seeing Korvin committing something to github for 8.2 that uses a different approach to autoloading the core concrete5 files, something to make it more efficient I believe.
dercin replied on at Permalink Reply
Thank you for your detailed answer.
Then perhaps we can hope for an update in the future.. :) I check my hosting.

Greetings from Germany.
dercin replied on at Permalink Reply
Okay I updated to 8.2.1 now.

Still the same Problem. The first load on a day is about 8 Seconds after that It's fast on all clients for the next hours.
Steevb replied on at Permalink Reply
Do u have the right code in your htaccess file for speed?

Do u have the right php settings and modules in place?

Do u have a URL we can look at?

Does ‘WebPageTest’ or ’Nibbler’ show any help with issues?
typoman76 replied on at Permalink Reply
I see exactly the same issue on some of my sites.
First load in the morning is very slow. After that constantly fast.
And its not the concrete5 cache. This happens with uncached site or with caching on.

It really looks like there is an initial load for the site and then cached with php or something else.

So if anyone has a good idea. I'm interested in a solution.
dercin replied on at Permalink Reply

Im sorry the website is still not public so I can't write the URL here. But I tested it with some tools, also nibbler and webpagetest and couldn't find any heavy problems yet. The important thing is, the tests could load the page in 1-2 seconds. It is only the first load a day, that is really slow. I will check tomorrow again and try to start with a test.

My htaccess is still quite empty:

AddType image/svg+xml .svg

# 1 Month for most static assets
<filesMatch ".(css|jpg|jpeg|png|gif|js|svg|ico)$">
Header set Cache-Control "max-age=2592000, public"

<ifmodule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE image/svg+xml
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

# -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
# -- concrete5 urls end --

This a part of Website info in c5

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - On
Full Page Caching - On - If blocks on the particular page allow it.
Full Page Cache Lifetime - Only when manually removed or the cache is cleared.

# Server Software

# Server API

# PHP Version

# PHP Extensions
bcmath, bz2, calendar, cgi-fcgi, Core, ctype, curl, date, dba, dom, enchant, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imagick, imap, intl, json, libxml, limiter, mbstring, mcrypt, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, posix, pspell, readline, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib

# PHP Settings
max_execution_time - 90
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 10000
memory_limit - 256M
post_max_size - 96M
sql.safe_mode - Off
upload_max_filesize - 96M
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
opcache.max_accelerated_files - 7963
opcache.max_file_size - 0
opcache.max_wasted_percentage - 5

In config I activated imagick.