Skip to content

DokuWiki Performance Optimization — Caching, Compression, CDN, and Tuning

DodaTech Updated 2026-06-28 7 min read

In this tutorial, you'll learn how to optimize DokuWiki for performance, including Caching configuration, gzip compression, CDN integration, PHP tuning, web server configuration, and performance monitoring.

What You'll Learn

  • Performance bottlenecks in DokuWiki
  • Caching configuration and optimization
  • Gzip compression for faster transfers
  • CDN integration for global audiences
  • PHP optimization for DokuWiki
  • Web server tuning (Apache/Nginx)
  • Performance monitoring and benchmarking

Why It Matters

A slow wiki frustrates users and reduces productivity. Every second of load time matters — users expect pages to load in under 2 seconds. DokuWiki is fast by nature (no database), but improper configuration can slow it down. Performance optimization ensures your wiki stays fast as it grows from 10 to 10,000 pages.

Real-World Use

A wiki with 2,000 pages and users across three continents loads in 3-5 seconds on average. The admin implements: rendering cache (reduced to 100ms), gzip compression (reduced transfer size by 70%), CDN for static assets (reduced latency by 60%), and PHP opcode caching (reduced PHP execution time by 50%). The wiki now loads in under 500ms globally.

Learning Path

flowchart LR
  A[Migration] --> B[Performance]
  B --> C[Security]
  C --> D[Production]
  D --> E[Conclusion]

Performance Bottlenecks

DokuWiki's main performance factors are:

Factor Impact Solution
Disk I/O High (reading .txt files) SSD storage, filesystem caching
PHP execution Medium Opcode caching, PHP version
Cache miss High (Parsing .txt to HTML) Proper caching configuration
Template rendering Medium Template caching
Network latency High (for remote users) CDN, compression

Caching Optimization

Enable and Tune Rendering Cache

<?php
// conf/local.php
$conf['cachetime'] = 86400;          // 24 hours cache lifetime
$conf['allowcache'] = 1;             // Cache for all users
$conf['cache'] = 1;                  // Enable caching

Monitor Cache Hit Rate

# Check cache directory age
# Fresh cache files indicate good cache hit rate
ls -la data/cache/p/ | tail -20

Disable Cache for Dynamic Pages

Add ~~NOCACHE~~ only to pages that change frequently (dashboards, blog listings).

Gzip Compression

Enable PHP Output Compression

<?php
// conf/local.php
$conf['gzip_output'] = 1;            // Compress HTML output
$conf['compression'] = 'gz';         // gz for gzip compression

Verify Compression

# Check if compression is working
curl -H "Accept-Encoding: gzip" -I https://yourserver/wiki/start
# Look for: Content-Encoding: gzip

CDN Integration

A CDN (Content Delivery Network) caches and serves static assets from edge locations close to users.

  1. Configure CDN to cache static assets (CSS, JS, images) with long TTL
  2. Use the CDN's origin pull to fetch from your server
  3. Configure DokuWiki to use CDN URLs for assets

DokuWiki CDN Configuration

<?php
// conf/local.php
$conf['proxy']['host'] = 'cdn.example.com';
$conf['proxy']['port'] = 80;
$conf['allowcache'] = 1;

Template CDN Integration

<?php
// In template's main.php, load assets from CDN
$cdnBase = 'https://cdn.example.com/wiki';
echo '<link rel="stylesheet" href="' . $cdnBase . '/lib/tpl/dokuwiki/css/style.css">';

PHP Optimization

Use a Recent PHP Version

# PHP 8.x is significantly faster than PHP 7.x
php --version

Each major PHP version brings performance improvements:

PHP Version Relative Performance
PHP 7.4 Baseline
PHP 8.0 ~20% faster
PHP 8.1 ~25% faster
PHP 8.2 ~30% faster

Enable Opcode Caching

OPcache is built into PHP. Ensure it is enabled:

; php.ini
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
opcache.revalidate_freq=60

PHP Memory Settings

; php.ini
memory_limit = 256M
max_execution_time = 120

Web Server Tuning

Apache

# Enable compression
AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript

# Enable KeepAlive
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5

# Enable expires headers for static assets
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/html "access plus 1 hour"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
</IfModule>

Nginx

# Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml;
gzip_min_length 1000;
gzip_vary on;

# Cache static assets
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg)$ {
    expires 30d;
    add_header Cache-Control "public, immutable";
}

# PHP-FPM settings
location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

Filesystem Optimization

Use SSD Storage

DokuWiki reads .txt files on every page request (when cache misses). SSD storage significantly reduces read latency.

Optimize with atime

Disable access time updates for the wiki directory:

# /etc/fstab
/dev/sda1 /var/www/html/wiki ext4 defaults,noatime,nodiratime 0 0

Directory Structure

Keep namespace depth reasonable (3-4 levels max) to avoid filesystem lookup overhead.

Performance Monitoring

Manual Performance Testing

# Measure page load time
time curl -s -o /dev/null https://yourserver/wiki/start

# Test with compression
time curl -s -o /dev/null -H "Accept-Encoding: gzip" https://yourserver/wiki/start

Using Apache Bench

# Simulate 100 requests with 10 concurrent users
ab -n 100 -c 10 https://yourserver/wiki/start

DokuWiki Performance Log

<?php
// Add to template or action plugin to log performance
$startTime = microtime(true);
// ... page generation code ...
$endTime = microtime(true);
$loadTime = ($endTime - $startTime) * 1000;

if ($loadTime > 500) {
    // Log slow pages
    $log = date('Y-m-d H:i:s') . "\t" . $ID . "\t" . round($loadTime) . "ms\n";
    file_put_contents(DOKU_INC . 'data/log/slow-pages.log', $log, FILE_APPEND);
}

Performance Checklist

[ ] Caching enabled (cachetime >= 3600)
[ ] Gzip compression enabled
[ ] OPcache enabled and configured
[ ] PHP version >= 8.1
[ ] Web server compression configured
[ ] Browser caching configured (expires headers)
[ ] CDN configured (if global audience)
[ ] SSD storage for wiki files
[ ] noatime mount option for wiki directory
[ ] Template cache enabled
[ ] Index updated regularly
[ ] Old attic files purged (cleanup script)
[ ] Page load time < 500ms
[ ] Cache hit rate > 80%

Common Mistakes

  1. Disabling caching entirely: Setting $conf['cache'] = 0 turns DokuWiki into a slow, synchronous parser. Always enable caching for production.
  2. Not enabling OPcache: PHP OPcache is one of the highest-impact optimizations. Without it, PHP re-parses every file on every request.
  3. Using a single server for everything: Separate the web server, PHP, and static file serving across services for optimal resource usage.
  4. Not monitoring performance: Without metrics, you cannot know if your optimizations work. Measure page load times before and after each change.
  5. Over-aggressive caching: Setting infinite cache TTLs means users see stale content. Balance freshness with performance.

Practice Questions

  1. What are the three most impactful performance optimizations for DokuWiki?
  2. How does gzip compression improve performance, and how do you enable it in DokuWiki?
  3. Why is PHP OPcache important for DokuWiki performance, and how do you configure it?
  4. Challenge: Create a performance benchmark for a DokuWiki wiki. Measure: page load time for 5 different pages (start page, content page, page with images, search results, admin page), cache hit rate (check cache file ages), PHP execution time (add timing code to template), and server resource usage (CPU, memory with top or htop). Implement three performance optimizations, re-measure, and document the improvements. Target: 50% reduction in page load time.

FAQ

How fast should a DokuWiki page load?

A well-optimized DokuWiki page should load in under 500ms from the server, and under 2 seconds total including network and rendering. If your wiki takes longer than 2 seconds, there is room for optimization.

Does DokuWiki benefit from PHP 8's JIT compiler?

Yes, but the impact is moderate. DokuWiki is I/O-bound (reading files), not CPU-bound (computation). JIT helps with complex page rendering but the bottleneck is usually disk I/O and cache misses.

Should I use a CDN for my wiki?

If your users are geographically distributed, yes. A CDN caches static assets at edge locations, reducing latency. The DokuWiki rendering cache handles dynamic content — a CDN cannot cache authenticated or personalized content.

How do I identify slow pages in my wiki?

Add performance logging to your template or use an action plugin that logs page load times. Pages that take longer than 500ms to generate are candidates for optimization — often due to complex plugins or missing cache.

Is Nginx or Apache better for DokuWiki?

Both work well. Nginx typically uses less memory under high concurrency. Apache is easier to configure with .htaccess files. Choose based on your server administration expertise and expected traffic levels.

Mini Project

Goal: Optimize a DokuWiki wiki and measure the improvements.

  1. Measure baseline performance: page load time for 5 pages, cache directory size, PHP memory usage
  2. Enable gzip compression and verify it works
  3. Enable and configure OPcache
  4. Configure browser caching for static assets
  5. Set appropriate cache TTL values
  6. Purge old attic files (keep 10 most recent revisions)
  7. Rebuild the search index
  8. Measure performance after each optimization
  9. Create a performance report with before/after comparisons
  10. Document ongoing maintenance for sustained performance

What's Next

Performance optimization keeps your wiki fast. Now learn about security hardening to protect your wiki from threats.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro