Websites
Caching, compression and CDN
Make sites fast with the nginx page cache or microcaching, a private Valkey object cache per subscription, long browser cache times with WebP and AVIF, a Cloudflare or Bunny CDN, HTTP/2, HTTP/3 and Brotli.
On this page
A Berth website has several speed layers that you switch on per domain: a page cache in nginx, an object cache for the application, browser cache times for static files with modern image formats, and an optional CDN in front. This article explains what each layer does, when to use it, and how it stays correct when content changes.
All of these settings live on the domain page under Speed. Customers can manage them for their own domains.
How a request travels
nginx accepts every request. It serves static files (images, CSS, JavaScript, fonts, downloads) itself and passes the rest to Apache, which runs PHP through the subscription's own PHP-FPM. The page cache sits in nginx, in front of Apache and PHP; the object cache sits behind PHP, in front of the database.
visitor ─► CDN (optional) ─► nginx ─┬─► static file from disk (browser cache times, WebP/AVIF)
├─► page cache HIT
└─► Apache ─► PHP-FPM ─┬─► object cache (Valkey)
└─► MariaDB / PostgreSQLPage cache
With the page cache on, nginx stores the pages your site produces and serves them itself for the chosen time, without PHP or the database. That makes pages much faster and keeps a site standing during a traffic peak.
What is never cached:
- visitors who are logged in,
- form submissions and other non-GET requests,
- URLs with a query string (searches, filters); with microcaching these are cached too, for the few seconds you chose,
- shopping carts and checkout,
- admin pages such as
/wp-admin, - responses that set a cookie or ask for
no-storethemselves.
WordPress and WooCommerce are recognised automatically. The response header X-Cache shows whether a page came from the cache (HIT).
Choose a cache time
Open Speed → Page cache, switch it on and choose a Cache time:
| Option | Times | Good for |
|---|---|---|
| Microcaching | 1, 5 or 10 seconds | Dynamic sites: content stays practically live, while a burst of identical requests is answered from one PHP run |
| Page cache | 5, 10 or 30 minutes, 1 or 4 hours, 1 day | Sites whose pages change a few times a day or less |
berth domain cache --domain example.com --on --ttl 30 # 30 minutes
berth domain cache --domain example.com --on --seconds 5 # microcaching
berth domain cache --domain example.com --offStale content and stampedes
The cache is configured so that a site stays up when the application has trouble. When a cached page expires, the first visitor triggers a refresh in the background while others still get the previous version; only one request at a time fills an entry. If PHP answers with an error or times out, nginx keeps serving the last good version.
Purge
After a change, visitors see the new version after the cache time at the latest, or immediately after Clear cache.
berth domain cache --domain example.com --purgeFor WordPress, a small plugin clears the affected pages as soon as you publish or change something, so you rarely need the button. If a CDN is linked, clearing the page cache clears the CDN too.
Object cache (Valkey)
Applications such as WordPress, WooCommerce and Laravel can keep the results of expensive database queries in an object cache. Berth gives every subscription its own Valkey (the open-source continuation of Redis):
- reachable only by the subscription's own websites, over a unix socket,
- no password needed, and each website gets its own key prefix,
- memory only: nothing is written to disk,
- it runs inside the subscription's resource slice, so it counts towards its memory limit.
Switch it on under Speed → Object cache and pick a size (from 32 MB up). The section shows memory use, number of keys and the hit rate. Clear object cache flushes it.
berth subscription objectcache --sysuser acme --on --size 128
berth subscription objectcache --sysuser acme --flushWordPress is linked with one button on the WordPress page (Object cache → Link WordPress). That installs the Redis Object Cache plugin and writes the connection into wp-config.php.
berth wp objectcache --domain example.com --linkOther applications connect with any Redis client to the socket path shown in the section. The package option Object cache (own Valkey per subscription) decides whether a subscription may have one; it is on by default.
Static files and browser cache times
Under Speed → Static files you choose how long browsers may keep files, per type: images, CSS and JavaScript, fonts, video and audio, documents and downloads. Options run from off and no-cache through 1 hour, 1 day, 7 days and 30 days to 1 year. The default is 7 days for everything.
Long times (30 days, 1 year) are faster, but a changed file with the same name reaches visitors later. WordPress and most frameworks put a version number in the URLs of CSS and JavaScript, which makes 1 year safe for those.
berth domain static --domain example.com --images 30d --css-js 1y --fonts 1y
berth domain static --domain example.com --resetWebP and AVIF
With Offer WebP and AVIF on, the panel creates a smaller WebP and AVIF version of every JPEG and PNG (photo.jpg.webp, photo.jpg.avif), but only when it is actually smaller. nginx serves it to browsers that ask for it; others get the original, which always stays in place. New images are converted every night, or immediately with Convert now.
berth domain static --domain example.com --modern-images on
berth domain images convert --domain example.com
berth domain images status --domain example.comWhen .htaccess must apply to static files
Because nginx serves static files itself, rules in .htaccess (a password on a download folder, Deny from all, a hotlink rule) do not apply to them. Plesk behaves the same way. If you rely on such rules, switch on Everything via Apache. All files then go through Apache. It is a little slower, and it cannot be combined with WebP/AVIF.
berth domain static --domain example.com --via-apache onCDN: Cloudflare or Bunny
If a site sits behind Cloudflare or Bunny, link it under Speed → CDN. Choose the provider, enter the zone ID (Cloudflare) or pull zone ID (Bunny) and an API key. Two things change:
- Real visitor addresses. nginx takes the visitor's address from the CDN's header, but only from the provider's published address ranges, which the panel refreshes daily. Logs, statistics, PHP, the WAF and bans all see the real visitor instead of the CDN.
- Purging. Clearing the page cache, or publishing in WordPress, also clears the cache at the CDN. Clear CDN does it by hand.
The API key only needs the right to purge the cache. For Cloudflare that is Zone · Cache Purge and Zone · Read.
berth domain cdn --domain example.com --provider cloudflare --zone <zone-id> --token-file -
berth domain cdn --domain example.com --purge
berth domain cdn --domain example.com --provider off
berth cdn refresh # refresh the providers' address lists nowProtocols and compression
- HTTP/2 is always on for HTTPS sites.
- HTTP/3 (QUIC over UDP port 443) is a server-wide switch, off by default. An administrator turns it on under Settings → Panel → HTTP/3. It applies to every site with a certificate and to the panel; browsers that cannot use it fall back to HTTP/2. The panel's own firewall opens UDP 443 by itself, but a firewall in front of the server must allow it as well.
- Compression: nginx compresses text responses, including PHP output from Apache, with Brotli for browsers that support it and gzip for the rest, and serves pre-compressed
.brfiles when they exist. - TCP tuning: the server uses BBR congestion control with fair queueing, and does not fall back to a slow start on an idle keep-alive connection. That helps visitors on mobile and long-distance connections. Where the kernel does not support it, the setting is left out.
Check the effect
The domain's quality score has a performance part that checks most of the above: page cache, object cache for WordPress, static cache times, WebP/AVIF, HTTP/3, a recent PHP version and whether PHP processes ran out. With Core Web Vitals measurement on, it shows real-world loading figures too. Busy PHP pools are covered in PHP, and per-site traffic and response codes in Statistics and metrics.