If you run your WordPress website on the Caddy web server, the Caddyfile is one of the most important configuration files you will work with.
It controls how Caddy serves your site, how it handles PHP, caching, compression, HTTPS, and much more.
Good news: Caddy is much simpler than Apache or Nginx.
It does not use .htaccess files, and most configuration happens in a single readable file called Caddyfile.
Why You Should Update Your Caddyfile
Updating your Caddyfile is important because it enables modern features that make your WordPress site faster, safer, and more compatible with new browsers.
Below are the main reasons.
1. Better Performance with Compression
Caddy supports Brotli, Zstd, and gzip compression out of the box.
These reduce file sizes and speed up page loads.
Updating the Caddyfile ensures Caddy automatically compresses:
- CSS & JS files
- Images (AVIF, WebP)
- Fonts (WOFF2)
- PHP-generated HTML
2. Improved Browser Caching
Modern WordPress themes rely on long-term caching for images, fonts, and scripts.
The updated Caddyfile sends proper Cache-Control headers so browsers can reuse files for up to one year.
This makes your website load much faster for visitors.
3. Proper Font Loading with CORS
Many themes load local webfonts using @font-face.
Browsers sometimes block fonts unless the server sends CORS headers.
The updated Caddyfile fixes this automatically.
4. Correct WordPress Permalink Support
Without the right setting, clicking posts or pages may show a 404 error.
The updated Caddyfile includes the recommended:
try_files {path} {path}/ /index.php?{query}
This ensures WordPress permalinks always work.
5. Modern Security Headers
Your site becomes more secure with headers that protect against:
- Clickjacking
- MIME-type spoofing
- XSS attacks
- Unsafe referrers
6. Compatible with PHP 8.3 on Debian 13
The updated configuration connects Caddy to the correct PHP-FPM socket used on Debian 13.
If this line is wrong, the site will show 502 errors.
Where to Find the Caddyfile
On Debian, the Caddyfile is usually located at:
/etc/caddy/Caddyfile
You can edit it using any text editor, for example:
$ sudo nano /etc/caddy/Caddyfile
How to Apply Changes
After editing the Caddyfile, always run:
$ sudo caddy validate --config /etc/caddy/Caddyfile
If it returns valid, reload Caddy:
$ sudo systemctl reload caddy
Reloading is safe: it does not interrupt active visitors.
What the Updated Caddyfile Does
Your updated Caddyfile includes:
- Automatic HTTPS with Caddy
- Full WordPress PHP processing
- Brotli, gzip, and zstd compression
- CORS support for fonts
- Long-term caching for images, CSS, JS, and fonts
- Security headers
- Correct permalinks
- Filesystem routing for WordPress
All of this improves speed, SEO, browser compatibility, security, and overall site health.
Conclusion
Updating your Caddyfile is one of the easiest and most effective ways to improve your WordPress site.
With just a few lines of configuration, you get:
- Better performance
- Better security
- Modern browser support
- No need for .htaccess files
- Everything managed cleanly from one file
Caddy is designed to be simple, powerful, and secure.
Once your Caddyfile is updated properly, your WordPress site will run faster and more reliably than on traditional servers.