feat(web-arm): add AVIF image support to cloonar.dev
Implement AVIF image content negotiation with WebP fallback for cloonar.dev website. Browser will receive AVIF if supported and available, otherwise WebP, falling back to original JPEG/PNG. - Add AVIF-first content negotiation in image location block - Maintain existing WebP fallback logic - Include .avif in long-term cache headers (365d) - Add Vary: Accept header for proper CDN/browser caching AVIF files should be placed at /avif/$request_uri.avif to be served. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -14,20 +14,42 @@ in {
|
||||
'';
|
||||
|
||||
locations."~* \.(jpe?g|png)$".extraConfig = ''
|
||||
set $red Z;
|
||||
set $img_format Z;
|
||||
|
||||
# Check for AVIF support (highest priority)
|
||||
if ($http_accept ~* "avif") {
|
||||
set $img_format A;
|
||||
}
|
||||
|
||||
if (-f $document_root/avif/$request_uri.avif) {
|
||||
set $img_format "''${img_format}V";
|
||||
}
|
||||
|
||||
# Serve AVIF if supported and available
|
||||
if ($img_format = "AV") {
|
||||
add_header Vary Accept;
|
||||
rewrite ^ /avif/$request_uri.avif break;
|
||||
}
|
||||
|
||||
# Reset and check for WebP support (fallback)
|
||||
set $img_format Z;
|
||||
|
||||
if ($http_accept ~* "webp") {
|
||||
set $red A;
|
||||
set $img_format W;
|
||||
}
|
||||
|
||||
if (-f $document_root/webp/$request_uri.webp) {
|
||||
set $red "''${red}B";
|
||||
set $img_format "''${img_format}P";
|
||||
}
|
||||
|
||||
if ($red = "AB") {
|
||||
# Serve WebP if supported and available
|
||||
if ($img_format = "WP") {
|
||||
add_header Vary Accept;
|
||||
rewrite ^ /webp/$request_uri.webp;
|
||||
rewrite ^ /webp/$request_uri.webp break;
|
||||
}
|
||||
|
||||
# If neither AVIF nor WebP matched, serve original format
|
||||
add_header Vary Accept;
|
||||
'';
|
||||
|
||||
locations."^~ /vcards/".extraConfig = ''
|
||||
@@ -40,7 +62,7 @@ in {
|
||||
try_files $uri $uri/ /vcards/index.php$is_args$args;
|
||||
'';
|
||||
|
||||
locations."~* \.(js|jpg|gif|png|webp|css|woff2)$".extraConfig = ''
|
||||
locations."~* \.(js|jpg|gif|png|webp|avif|css|woff2)$".extraConfig = ''
|
||||
expires 365d;
|
||||
add_header Pragma "public";
|
||||
add_header Cache-Control "public";
|
||||
|
||||
Reference in New Issue
Block a user