Ana içeriğe geç

XenForo 2.3 WebP Optimization & Offloading Attachments to Cloudflare R2 / S3

XenForo 2.3 WebP Optimization & Offloading Attachments to Cloudflare R2 / S3

Administrator
XenForo 2.3 WebP Optimization & Offloading Attachments to Cloudflare R2 / S3
High-resolution user attachments and avatars quickly consume local NVMe storage and slow down thread page loads on active communities. Combining XenForo 2.3's native WebP image optimization with S3-compatible object storage such as Cloudflare R2 or Amazon S3 reduces file sizes by up to 50% while offloading media bandwidth from your origin server.



Enabling Native WebP Image Optimization in XenForo 2.3
Before activating WebP conversion, confirm that your server's PHP GD or Imagick extension has WebP support compiled in by checking AdminCP > Tools > PHP info. Once verified, enable automatic optimization for all newly uploaded images:
  1. Navigate to AdminCP > Setup > Options > Attachments and locate the Image optimization setting.
  2. Set the optimization mode to Optimize to WebP and save your changes so JPEG and PNG uploads are automatically converted upon upload.
  3. To convert existing attachments uploaded prior to upgrading, open AdminCP > Tools > Rebuild caches and run the Optimize attachments job.



Offloading Data and Attachments to Cloudflare R2 or Amazon S3
XenForo uses an abstract filesystem layer that allows you to route public assets (data/) and private attachments (internal_data/) to external object storage using XenForo's official Amazon S3 / DigitalOcean Spaces add-on. Because Cloudflare R2 is fully S3-compatible and charges zero egress bandwidth fees, it is widely preferred for high-traffic forums.

Before modifying your configuration, synchronize your existing local data/ and internal_data/ directories to your target bucket using rclone or the AWS CLI so older attachments do not return 404 errors. Next, configure your custom filesystem adapters in src/config.php:
Kod:
$s3Config = [     'key' => 'YOUR_ACCESS_KEY_ID',     'secret' => 'YOUR_SECRET_ACCESS_KEY',     'region' => 'auto',     'endpoint' => 'https://YOUR_ACCOUNT_ID.r2.cloudflarestorage.com',     'bucket' => 'your-forum-bucket' ]; $config['fsAdapters']['data'] = function() use ($s3Config) {     return \XFAws\Flysystem\Adapter\S3::create($s3Config, 'data'); }; $config['fsAdapters']['internal-data'] = function() use ($s3Config) {     return \XFAws\Flysystem\Adapter\S3::create($s3Config, 'internal_data'); };


Serving Public Assets Through a Custom CDN Domain
Routing data/ files through PHP defeats the performance benefit of external storage. Connect a custom subdomain (such as cdn.yourdomain.com) to your public R2 bucket or CloudFront distribution, then define $config['externalDataUrl'] in src/config.php so avatars and attachment thumbnails load directly from the edge:
Kod:
$config['externalDataUrl'] = 'https://cdn.yourdomain.com/data';
Leave internal-data without a direct public URL so XenForo continues enforcing forum permissions before streaming full-size protected attachments.
İşin Doğrusu Youtube Kanalı

Konu ile Alakalı Benzer Konular

Zamanlanmış görev