Image Preview Cache Duration -- can I change it?

I’m running NC 12.0.3 on Raspbian Stretch (installed using NextCloudPi), and one of my uses is to share a fairly large number of photos (a few thousand) with my extended family. Obviously the Pi is no speed demon, but when once previews have been generated for all the photos, I’m finding that NC is really pretty snappy.

The trouble comes once the a particular folder/gallery hasn’t been visited in a while, and the previews need to be regenerated – takes forever, and runs the Pi to the point of exhaustion. I’m assuming that the image previews are cached somewhere, and for some pre-determined length of time. Is there a way to control this? I’d like to make the default cache time significantly longer for images (I have plenty of disk space, so that’s not a concern for me). I’ve seen this mentioned in passing occasionally, but I’ve looked around a bit, and couldn’t find anything mentioned in the documentation.

Hmmm, I’m not aware of there being any limitation on the cache, but @rullzer knows more about the caching than anyone. In any case, perhaps it would make sense to regularly use this app:

run it at night, it might solve the problem.

The previews are generally created on demand (requested to show on files app, gallery etc.) and stored in /data/previews_<instanceid> without time limitations, as far as I know. I guess php file caching (APCu) can cache them to memory and browsers into their browser cache, but the previews (in different sizes) just need to be created once.

As this creation can take a while, you can use the app mentioned by @jospoortvliet to pre generate them regularly or at night, so they will show up much faster on first access withing web ui/gallery app.

@jospoortvliet That sounds like it might indeed solve the problem – I’ll give it a try. Many thanks!

@MichaIng, this is great information – I really appreciate it. This certainly gives me a good starting point to look into what’s happening behind the scenes. It hadn’t occurred to me that it could be a browser caching issue. My experience has been that if I don’t open any given gallery folder for more than a few days, it takes forever to reload. I was assuming that some kind of cache was being purged, and that the previews were being re-generated, but from what you’re saying, that’s probably not the case.

If anyone else out there has any additional insight to add, I’m still very interested to hear about it.

So just to clarify:

  • Previews are cached server side
  • Whenever possible we also cache previews client side
    • Not all gallery endpoints allow this yet

Indeed using the previewgenerator is probabaly a good idea. As it will just continue generating previews. So probabaly then at least some are already available when you want to view your images.