Cache static web assets with apache/traefik

I’m running Nextcloud with Docker and it seems to be working fine. I’m wondering if I can/should take any additional steps to improve cache static assets such as JavaScript files and images to speed things up a bit server-side.

But: In my browser console Network tab I already see cache-related headers in responses (etag, cache-control, last-modified), it feels fast (enough), and it looks like most images and JavaScripts are often cached already, so I’m thinking maybe the answer is “no”/“not necessary”/“just leave it as-is.”

  • Nextcloud version: 29.0.4 / Hub 8, from the community Docker image tagged nextcloud:stable
  • Host: Docker (compose) running on 64-bit Ubuntu 22.04 LTS server
  • Web server: Apache 2.4.61
  • PHP version: 8.2.21

I’m doing ad-hoc performance tests with Firefox on a desktop, but I also use Nextcloud with other clients (e.g. my Android phone). For the sake of this thread, let’s limit to talking about using Nextcloud from a web browser.

My Docker compose config file looks pretty much like this, with variables substituted in (e.g. my actual domain name). Per that config I’m using Redis and MariaDB. Both seem to be working fine.

I checked the admin manual and I found info about other types of caching, and some bits about Nginx that don’t apply for my setup.

I’m using OPCache (I recall that’s in the community Docker image).

I’m not even sure what I’d use for caching. Maybe add Varnish somewhere? Tweak Apache config? I don’t see related settings in the Traefik proxy docs.

I’m not an expert in web technology tweaking but from my experience as system engineer I would recommend to follow defaults when possible. Every customization you apply potentially breaks something in the future. As far I see most assets are cached locally (as long your browser is allowed to use enough disk cache) and not many data is loaded from the server… no need for additional webserver cache IMHO.

Thanks @wwe ! I appreciate your expert opinion.

Agreed as always re: “if it ain’t broke, don’t fix it.” – local caching already really helps speed things up.

Also: server-side caching of static assets seems pretty safe, but perhaps of limited value for small-scale Nextcloud instances. At larger scale, it may be more worth it. I was just surprised my browser does not appear to be sending, for example, the If-None-Match header.

1 Like