Last active
April 3, 2024 14:06
-
-
Save mklooss/7dc74a417238c00a878ac5da80f254af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map $http_accept $webp_suffix { | |
default ""; | |
"~*webp" ".webp"; | |
} | |
pagespeed XHeaderValue "Powered By ngx_pagespeed"; | |
location ^~ /thumbnail/ { | |
pagespeed off; | |
expires 1y; | |
add_header Pragma public; | |
add_header Cache-Control "public"; | |
add_header X-OUPUT static; | |
try_files /webp/$uri$webp_suffix $uri =404; | |
} | |
location ^~ /media/ { | |
pagespeed off; | |
expires 1y; | |
add_header Pragma public; | |
add_header Cache-Control "public"; | |
add_header X-OUPUT static; | |
try_files /webp/$uri$webp_suffix $uri =404; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WebP | |
15 */1 * * * bash /home/USER/bin/webpconvertOnlyNewFiles.sh > /dev/null | |
30 23 * * 7 bash /home/USER/bin/webpconvertComplete.sh > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BOF: WEBP | |
AddType image/webp .webp | |
RewriteCond %{REQUEST_URI} (thumbnail|media) | |
RewriteCond %{HTTP_ACCEPT} image/webp | |
RewriteCond %{REQUEST_FILENAME} -f | |
RewriteCond %{REQUEST_URI} \.(jpg|png)$ [NC] | |
RewriteCond %{DOCUMENT_ROOT}/webp%{REQUEST_URI}.webp -f | |
RewriteRule ^ /webp%{REQUEST_URI}.webp [L,T=image/webp] | |
# EOF: WEBP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# File Location: /home/USER/bin/webpconvert.sh | |
FILEPATH=$(echo $1) | |
echo "$FILEPATH" | |
DIRNAME=$(dirname "$FILEPATH") | |
BASEPATH=$(basename "$FILEPATH") | |
NEWDIR="webp/${DIRNAME}" | |
echo " " | |
echo $DIRNAME | |
echo $BASEPATH | |
mkdir -p "webp/$DIRNAME" | |
echo " " | |
cwebp "$FILEPATH" -o "${NEWDIR}/${BASEPATH}.webp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# File Location: /home/USER/bin/webpconvertComplete.sh | |
# Shopware 6 Sample! | |
cd /home/USER/htdocs/public && find thumbnail/ -type f -iname "*.png" -exec webpconvert.sh "{}" \; | |
cd /home/USER/htdocs/public && find thumbnail/ -type f -iname "*.jpeg" -exec webpconvert.sh "{}" \; | |
cd /home/USER/htdocs/public && find thumbnail/ -type f -iname "*.jpg" -exec webpconvert.sh "{}" \; | |
cd /home/USER/htdocs/public && find media/ -type f -iname "*.png" -exec webpconvert.sh "{}" \; | |
cd /home/USER/htdocs/public && find media/ -type f -iname "*.jpeg" -exec webpconvert.sh "{}" \; | |
cd /home/USER/htdocs/public && find media/ -type f -iname "*.jpg" -exec webpconvert.sh "{}" \; | |
find /home/USER/htdocs/public/webp -type f -mtime +2 -exec rm -f "{}" \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# File Location: /home/USER/bin/webpconvertOnlyNewFiles.sh | |
# Shopware 6 Sample! | |
cd /home/USER/htdocs/public && find thumbnail/ -newermt '2 hour ago' -type f -iname "*.png" -exec webpconvert.sh "{}" \; | |
cd /home/USER/htdocs/public && find thumbnail/ -newermt '2 hour ago' -type f -iname "*.jpeg" -exec webpconvert.sh "{}" \; | |
cd /home/USER/htdocs/public && find thumbnail/ -newermt '2 hour ago' -type f -iname "*.jpg" -exec webpconvert.sh "{}" \; | |
cd /home/USER/htdocs/public && find media/ -newermt '2 hour ago' -type f -iname "*.png" -exec webpconvert.sh "{}" \; | |
cd /home/USER/htdocs/public && find media/ -newermt '2 hour ago' -type f -iname "*.jpeg" -exec webpconvert.sh "{}" \; | |
cd /home/USER/htdocs/public && find media/ -newermt '2 hour ago' -type f -iname "*.jpg" -exec webpconvert.sh "{}" \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment