NextCloudPi first connect to the page needs long time

Since Iā€™m using NextCloudPi instead of the normal NextCloud I have the problem that the first connect to my page needs years. If Iā€™m connected once then everything is fine and has normal loading times.
The strange thing is that when Iā€™m not logged in the page also loads instantly. But if I was already logged in with this device and then call my URL it needs like 30-40 seconds or sometimes even more I think. Iā€™m hosting it at home with a Raspberry Pi 3 Model B Rev 1.2. I use a FritzBox 7362SL to redirect it with spdyn.
Everything in NCP is updated and up-to-date.

Do you have any idea whatā€™s the issue?

Hi,
Iā€™d say thatā€™s at least partly due to caching and it takes a while when you first log in because the cache has expired beforehand. 30-40s is a long time though so there might be something else in the mix, like network speeds and errors. Test your network with things like file transfers and directory listings that donā€™t directly involve nextcloud, especially if itā€™s wireless. Then thereā€™s optimising the pi3 itself for server work. I have my GPU set to the minimum (16MB) and itā€™s clocked to 1.2GHz.

I donā€™t know how to get better caching or something then. File transfers and like I said everything when you are inside NextCloud one time itā€™s fine. Everything is working good. Just the first attempt to the website is horrible and I donā€™t know why. I donā€™t think that this is a performance issue caused by no overclocking.

What I mean to convey is the fact that the first time you log in, you see the real speed of the pages being firstly generated by the pi and secondly served over the network, because nothing will be cached.

Better caching isnā€™t a solution. NC has to look at a database, load it then express the data through php in order for you to see a page for the first time since cache-expiry and that will be slow on a stock pi. The webserver and/or the database might be swapped out of memory to ā€˜diskā€™ beforehand (which on a stock pi will be the sd card) and these are slow. To get round this, I have had to connect a usb-powered harddrive (as this setup is much faster than a sd card), set swap to use a partition on that disk and set all my data directories to that disk, overclock my pi (not itself without risk to the pi - see the raspberry pi boards for advice about this) and then ensure my network is fine (itā€™s wired not wireless) to get acceptable results.

Iā€™d first look at load on the pi in a terminal window while loading NC for the first time in a while to see if itā€™s at least partly an issue with that.

Really? The access to the USB-Stick will is faster than the microSD? I canā€™t believe because I already picked a fast microSD. I mean itā€™s no problem to port all of the data and stuff to the USB Stick. At the moment I use the microSD as storage for the most things and the USB is just plugged in when it gets full.

Not stick. Hard drive. USB-powered hard drive. One of these:
https://www.adata.com/en/feature/478

Generally, when I set up a system that boots from an SD card, I make it so that all the places that get written to a lot (like swap and /tmp and /var), go on hardware thatā€™s meant to be written to a lot. An actual hd is more this type of hardware than an SD.

Ok thank you. Iā€™ll try it then. Does it need to be a good external HDD with good speeds? I dont think so because itā€™s USB 2.0 anyway or am I wrong? I mean I got a lot of old HDDs here. Some that I changed from internal HDD to external HDD with a case.

thatā€™d work.

Itā€™s a usb2 interface, so usb2 ā€œspeedsā€. What I seek to avoid on sdcard systems is thrashing of the sdcard due to write amplification (see https://en.wikipedia.org/wiki/Write_amplification ) and the issues around the fact that an sdcard write takes much longer than a read ( https://www.quora.com/Why-are-SD-cards-slower-than-hard-drives ) so it makes sense to have stuff that gets written to a lot on something fast, be it a tmpfs in memory or an actual hard drive. These affect performance independently of the speed of the interface. And itā€™s independent of OS - Iā€™m just mentioning it because itā€™s how I prep sdcard systems thatā€™ll need to read and write a lot of data, and need to be quick about it.

But before you do all that work, maybe look at load on the pi from a terminal window when you first load NC, and/or load another website onto the pi see how long it loads, and/or do other network tests. Because any sdcard issue might not be the major issue causing the slowness.