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.