Fast Display Images for XenForo

Fast Display Images for XenForo

Fast-Display-Images-for-XenForo.webp


The Fast Display Images feature is designed to improve performance and reduce memory usage in XenForo by bypassing the built-in PHP image handling. Instead of letting XenForo process and serve image attachments, this method uses either X-Sendfile (Apache) or X-Accel-Redirect (Nginx) to deliver files directly from the web server.

This approach is particularly useful for forums with large image attachments, as it lowers PHP’s workload and allows the web server to efficiently stream files to users.

Important note, when using this method, everyone can see all the images on the forum. If your forum needs image protection, you should not use it.

Key Benefits:
  • Lower RAM usage: PHP does not load and buffer images.
  • Better performance: Images are streamed directly by the web server.
  • Scalable: Handles large files with minimal server overhead.
  • Flexible: Supports both Apache (X-Sendfile) and Nginx (X-Accel-Redirect).
How It Works:
  • A custom image.php script handles image requests.
  • The script checks the attachment and, if available, sends headers for X-Sendfile or X-Accel-Redirect.
  • The web server delivers the file directly, skipping PHP’s memory-intensive file reading.
Installation Steps:
1. Download and Configure image.php

  • Download the provided image.php file. (XenVn Setting -> Attachments -> View All Image Attachments -> Fast Display Images)
  • Open the file and configure:
    • ACCELERATION -> Set to apache (Apache X-Sendfile) or nginx (Nginx X-Accel-Redirect).
    • NGINX_ALIAS -> (Only for Nginx) Define the internal alias path if required.
  • Upload image.php to the XenForo root directory.
2. Update .htaccess in XenForo Root
Insert the following rules above the existing RewriteRule ^.*$ index.php [NC,L] line:
Code:
You must log in to view
(2 lines)

Configuring Apache with X-Sendfile
Step 1: Install the X-Sendfile Module

On Debian/Ubuntu:
Code:
You must log in to view
(1 lines)

Step 2: Enable the Module
Code:
You must log in to view
(1 lines)

Step 3: Configure Apache Virtual Host
Edit your XenForo site’s Apache configuration (e.g., /etc/apache2/sites-available/000-default.conf):
Code:
You must log in to view
(20 lines)

Restart Apache:
Code:
You must log in to view
(1 lines)

Step 4: Adjust image.php
Set:
PHP:
You must log in to view
(1 lines)

Configuring Nginx with X-Accel-Redirect
Step 1: Define an Internal Alias

Edit your Nginx server block (e.g., /etc/nginx/sites-available/xenforo):
Code:
You must log in to view
(17 lines)

Step 2: Adjust image.php
Set:
PHP:
You must log in to view
(2 lines)
This way, image.php will instruct Nginx to serve the file from /protected/.

Step 3: Restart Nginx
Code:
You must log in to view
(1 lines)

The Fast Display Images feature is a lightweight and powerful optimization for XenForo forums. By integrating X-Sendfile or X-Accel-Redirect, you offload image delivery to the web server, saving RAM and CPU while improving user experience.
This setup is highly recommended for busy forums with heavy image usage.

Results:
Fast Display Images for XenForo-1.webp


Fast Display Images for XenForo-2.webp
 
Last edited:
Similar content Most view View more
Back
Top Bottom