Optimal Loading Times for Nextcloud on Shared Hosting through Caching and Compression
Learn how to drastically improve loading times of your Nextcloud on shared hosting with caching and compression. Tips for faster work and better performance.
Why Loading Times Are Crucial for Nextcloud
Nextcloud is a powerful cloud solution, but on shared hosting, performance can sometimes lag. Especially when you synchronize many files or work with apps, slow loading times become noticeable. With the right optimizations – especially caching and compression – you can get the most out of your web hosting package. In this article, we show you how to speed up your Nextcloud instance.
Caching: The Turbo for Your Nextcloud
Caching stores frequently used data temporarily so it doesn't have to be reloaded every time. For Nextcloud on shared hosting, two types are particularly important:
1. Enable PHP Opcache
Nextcloud is written in PHP. The PHP Opcache stores compiled PHP scripts in memory. This reduces CPU load and greatly speeds up page loads. Ask your hosting provider if Opcache is enabled – with managed hosting, this is often standard.
2. Redis as Cache Backend
Redis is an in-memory data store that is perfect as a cache for file lists, sessions, and transaction data. Here's how to configure Redis for Nextcloud:
- Install the Redis server (if your hosting allows it) or use your provider's service.
- Add the following lines to
config.php:'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'redis' => [
'host' => 'localhost',
'port' => 6379,
],
This reduces database queries and noticeably lowers response times.
Compression: Less Data, Faster Transfer
Compression reduces the amount of data exchanged between server and browser. This is especially helpful with larger files and many simultaneous accesses.
Enable Gzip Compression
Most modern browsers support Gzip. Add the following lines to .htaccess (in the Nextcloud directory):
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascriptAlternatively, you can use PHP compression: set 'enable_compression' => true in config.php. Make sure your VPS server or shared hosting allows these settings.
Image Compression for Previews
Nextcloud creates thumbnails of images. These can become very large. Reduce the quality in the settings under "Thumbnails" to 75% or use a plugin like "Preview Generator" that creates and compresses thumbnails in the background.
Additional Tips for Faster Nextcloud
- Use HTTP/2: Many hosting providers support HTTP/2. This enables parallel requests and reduces latency. Ask your provider or switch to one that offers domain registration and modern hosting technology.
- Optimize Database: Regularly run
occ db:add-missing-indicesandocc db:convert-filecache-bigintto keep the database efficient. - Use a CDN: A Content Delivery Network (CDN) can deliver static assets like CSS and JavaScript. This relieves your server and speeds up delivery worldwide.
- Set Cache Headers: Set long cache headers for static files (images, CSS, JS) so the browser doesn't reload them constantly. Example in
.htaccess:ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
Shared Hosting Limits and Solutions
Shared hosting shares resources with other users. If you hit limits despite optimization, an upgrade to a virtual server might make sense. There you have dedicated resources and more control over caching and compression. But even on shared hosting, significant improvements can be achieved with the measures mentioned.
With these tips, your Nextcloud will be noticeably faster. Test the changes step by step and monitor performance with tools like Nextcloud's own status page or external speed tests. Good luck!