It's waaaay cheaper reading a cache file from disk than regenerating the image for every viewer.
Re-generating means:
- load attachment from file or database
- check if large enough, etc.
- load watermark file
- apply watermark file
- output
Loading from cache means:
- load cached image file
- output
Hard-disk drives use an internal page cache as well, so it's the best way to gain optimal performance.
For those with limited disk space, I implemented the cache table, which only keeps a fraction of the attachments which have been viewed recently in the cache. This should allow optimal control between performance and disk usage. Of course the worst case then would be, if an user views all attachment images one after another. But then again, it's a server and they're optimized to handle this kind of stuff.
If you have more questions or suggestions about performance and cache behaviour, feel free to ask