WebP Config
Quick Setup Guide — just installed or enabled this module?
Follow these steps to make sure the WebP/AVIF images are served to visitors:
- Generate the WebP images — if they have not been generated yet, open the Image regeneration > Regenerate WebP images tab (left menu) and run the generator.
- Regenerate the .htaccess rewrite rules (needed after re-enabling the module) — when you disable the module the rewrite rules are removed automatically, so after re-enabling them you need to put them back. Open the CDN Configuration tab (left menu) and click the Regenerate .htaccess Rules button. On a fresh install this happens automatically — you do not need to do this step.
You can also run step 2 if the WebP images have already been generated but they still do not show up on your site.
Still not working? If you completed steps 1 and 2 above and the WebP images are still not being served, as a fallback go to Shop Parameters → Traffic & SEO and in the Set up URLs section click Save. This triggers PrestaShop to regenerate the .htaccess file with the WebP/AVIF rewrite rules this module needs.
| Category | Original | Original Size | WebP | WebP Size | AVIF | AVIF Size | Missing |
|---|---|---|---|---|---|---|---|
| Products | 3496 | 59.02 MB | 3273 (93.6%) | 10.92 MB | 0 (0%) | 0 B | W: 223 A: 3496 |
| Categories | 532 | 3.47 MB | 136 (25.6%) | 232.99 KB | 0 (0%) | 0 B | W: 396 A: 532 |
| Manufacturers | 287 | 1.94 MB | 23 (8%) | 45.55 KB | 0 (0%) | 0 B | W: 264 A: 287 |
| Suppliers | 275 | 1.89 MB | 11 (4%) | 23.59 KB | 0 (0%) | 0 B | W: 264 A: 275 |
| Stores | 101 | 569.43 KB | 13 (12.9%) | 45.65 KB | 0 (0%) | 0 B | W: 88 A: 101 |
| CMS | 1 | 56.12 KB | 1 (100%) | 7.72 KB | 0 (0%) | 0 B | A: 1 |
| JPEG | 4692 files | 66.93 MB |
| PNG | 0 files | 0 B |
| WebP Savings | 55.67 MB (-77.2%) |
| AVIF Savings | 66.93 MB |
Compare your original images with their WebP and AVIF versions. Click on any image to see a side-by-side comparison with file size details.
What are orphan files?
Orphan files are WebP or AVIF images that no longer have a corresponding original image (JPG/PNG). This can happen when products or images are deleted from PrestaShop but the converted files remain.
Deleting orphan files is safe and will free up disk space. However, always backup your files before bulk deletion.
How it works:
- WebP rules are always included when this module is installed
- AVIF rules are automatically added when AVIF conversion is enabled in Settings
- CDN headers (Cache-Control, CORS) are added when CDN mode is enabled below
Regenerate .htaccess
Click the button below to update your .htaccess file with the latest WebP/AVIF rules.
You can also regenerate the .htaccess from: Shop Parameters > Traffic & SEO > click "Save"
Current Status
| WebP Rules | Enabled |
| AVIF Rules | Disabled (Enable in Settings) |
| CDN Headers | Disabled |
Nginx
Detected: No
Apache
Detected: No
Other/Unknown
Configuration may need adjustment
# ============================================================
# WebP Generator - Nginx Configuration
# Generated: 2026-10-07 05:06:00
# PrestaShop WebP/AVIF Image Serving Configuration
# ============================================================
# ============================================================
# MAPS - Browser capability detection
# Add these to http {} block or include file
# ============================================================
# Map for WebP support detection
map $http_accept $webp_suffix {
default "";
"~*webp" ".webp";
}
# Map for format preference (AVIF > WebP > Original)
map $http_accept $img_suffix {
default "";
"~*webp" ".webp";
}
# ============================================================
# LOCATION BLOCKS - Add these to server {} block
# ============================================================
# Image location with automatic WebP/AVIF serving
location ~* ^\/img/(.+)\.(jpe?g|png|gif)$ {
set $base $1;
set $ext $2;
# Try WebP if supported
set $webp_path $document_root/img/$base.webp;
if (-f $webp_path) {
set $webp_exists "true";
}
set $try_webp "${webp_exists}${webp_suffix}";
if ($try_webp = "true.webp") {
rewrite ^\/img/(.+)\.(jpe?g|png|gif)$ /img/$1.webp last;
}
# Browser caching
expires 1y;
add_header Cache-Control "public, immutable";
add_header Vary Accept;
etag on;
}
# WebP images
location ~* \.webp$ {
add_header Content-Type image/webp;
add_header Vary Accept;
expires 1y;
add_header Cache-Control "public, immutable";
etag on;
}
# Gzip compression for SVG and other compressible images
# Note: WebP and AVIF are already compressed, gzip won't help
gzip on;
gzip_types image/svg+xml;
gzip_vary on;
# ============================================================
# MIME TYPES - Add to http {} block if not already present
# ============================================================
# Add these MIME types to your mime.types file or types {} block:
types {
image/webp webp;
image/avif avif;
}
- Add the "map" blocks to your nginx.conf http {} block
- Add the "location" blocks to your site's server {} block
- Test configuration: nginx -t
- Reload Nginx: nginx -s reload
# ============================================================
# WebP Generator - Simple Nginx Configuration
# Quick setup for WebP/AVIF serving
# ============================================================
# Add this to your server {} block
location ~* ^/img/(.+)\.(jpe?g|png)$ {
add_header Vary Accept;
expires 1y;
try_files $uri$avif_suffix $uri$webp_suffix $uri =404;
}
# Required maps (add to http {} block)
map $http_accept $webp_suffix {
default "";
"~*webp" ".webp";
}
map $http_accept $avif_suffix {
default "";
"~*avif" ".avif";
}
# ============================================================
# WebP Generator - Apache .htaccess Configuration
# Generated: 2026-10-07 05:06:00
# ============================================================
# MIME Types for WebP and AVIF
<IfModule mod_mime.c>
AddType image/webp .webp
AddType image/avif .avif
</IfModule>
# Content negotiation for WebP/AVIF
<IfModule mod_rewrite.c>
RewriteEngine On
# Serve WebP if available and supported
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_FILENAME} (.+)\.(jpe?g|png|gif)$
RewriteCond %1.webp -f
RewriteRule ^(.+)\.(jpe?g|png|gif)$ $1.webp [T=image/webp,E=WEBP_FORMAT:webp,L]
</IfModule>
# Headers for caching and content negotiation
<IfModule mod_headers.c>
# Add Vary header for proper caching
<FilesMatch "\.(jpe?g|png|gif|webp|avif)$">
Header append Vary Accept
</FilesMatch>
# Cache control
<FilesMatch "\.(jpe?g|png|gif|webp|avif)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
</IfModule>
# Browser caching with mod_expires
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/avif "access plus 1 year"
</IfModule>
Best Practices
- Always include "Vary: Accept" header for proper caching
- Set long cache durations (1 year) for static images
- Use AVIF first, then WebP, then original format
- Test configuration before applying to production
- Monitor server logs after changes
Useful Commands
nginx -t
Test Nginx configuration
nginx -s reload
Reload Nginx configuration
apachectl configtest
Test Apache configuration
systemctl restart apache2
Restart Apache
Setting up the cron job through the server - (Recommended)
There are many servers and hosting management systems, but this guide will help you to set up the Cron Job. In order to set up the Cron Job, you need to open the page where you manage your domain.
Once you have entered the management interface you should look for something like Cron Jobs or Scheduled Tasks. Now it's time to enter the schedule and the command.
What's a Cron Job?
A cron job is a task that repeats every X time
The cron job can be divided in three parts the schedule and the command and the output
Schedule + Command + Output
For example, this Cron Job:
50 * * * * curl -l -k "https://webp.demo9.prestachamps.com/module/webpgenerator/cron?key=c2b2d28f6a271f6ce979649992e4886160a5287728117b419be61feab18519b2"
>/dev/null 2>&1
Will generate the images at minute 50 of every hour for every day and month indefinitely (0:50, 1:50, 2:50...)
Schedule - How does the schedule work?
The schedule tells the crob how often the command or script has to be executed.
In some systems, you will have to choose among prefedined options like once a day, every hour, every 3 hours... but in most cases, you will be able to choose the programmation yourself. To set up the schedule you will find 5 parameters to configure.
┌---------------- minute (0 - 59)
| ┌------------- hour (0 - 23)
| | ┌------------- day of month (1 - 31)
| | | ┌------------- month (1 - 12)
| | | | ┌------------- day of week (0 - 6), Sunday = 0 or 7
| | | | |
* * * * *
In each field you can set up a number or an asterisk.
The asterisk has the special meaning "every" ("every hour", "every minute"...)
You can also modify the asterisk operator by adding a slash and a number after it to set an interval.
To make it easier for you to understand. Here are the most common schedules to generate the missing WebP images:
| Schedule | What it does? | Will be executed at... |
|---|---|---|
| 0 * * * * | Generate the missing WebP images each hour at minute 0 | (0:00, 1:00, 2:00...) |
| 0 */3 * * * | Generate the missing WebP images every 3 hours at minute 0 | (0:00, 3:00, 6:00...) |
| 0 */6 * * * | Generate the missing WebP images every 6 hours at minute 0 | (0:00, 6:00, 12:00, 18:00, 24:00) |
| 0 */12 * * * | Generate the missing WebP images twice a day at minute 0 | (0:00, 12:00) |
| 0 0 * * * | Generate the missing WebP images once a day at minute 0 | (0:00) |
This behaviour can also be applied to the other modifiers, although you probably won't need to use it.
Schedule - How does the schedule work?
Once we know what schedule will be using, the next step is to call the script that will generate the missing WebP images. Depending on the system you use you will be asked for a URL or a command.
Here you will find all the options, you just need to click on the one you need to use to copy it to your clipboard.
Cron URL Click to copy the URL
https://webp.demo9.prestachamps.com/module/webpgenerator/cron?key=c2b2d28f6a271f6ce979649992e4886160a5287728117b419be61feab18519b2
The command
Use CURL: (recommended method) Click to copy the curl command
curl -l -k "https://webp.demo9.prestachamps.com/module/webpgenerator/cron?key=c2b2d28f6a271f6ce979649992e4886160a5287728117b419be61feab18519b2" >/dev/null 2>&1