By default, Nextcloud generates photo thumbnails on-demand that leads to slow Photos thumbnails load. To speed it up weβre using the Preview Generator app for Nextcloud to pre-generate previews regularly.
First we set the default thumbnail sizes by using the "occ config" commands:
sudo -u www-data /usr/bin/php /app/code/occ config:app:set --value="32 256" previewgenerator squareSizes
sudo -u www-data /usr/bin/php /app/code/occ config:app:set --value="256 384" previewgenerator widthSizes
sudo -u www-data /usr/bin/php /app/code/occ config:app:set --value="256" previewgenerator heightSizes
Then we generated previews for all existent images:
sudo -u www-data /usr/bin/php /app/code/occ preview:generate-all -vvv
It took about 3 weeks on our host to generate preview images for 4Tb of data which takes additional 500Gb.
Once it's finished we setup a cron job to generate previews:
0 */6 * * * sudo -u www-data /usr/bin/php -f /app/code/occ preview:pre-generate
TBH, it helped us a little but our Photos are still loading for 50-60 seconds and we are seeking any solution to speed it up.