• Just checking for feedback as I′m going to keep testing.

    I′m using aws cli to sync some of my uploads to s3:

    aws s3 sync –acl public-read uploads s3://bucketname/sh/wp-content/uploads/

    Following this and this for ideas…

    Could we make webp express call wp_update_attachment_metadata or a custom one each time it creates a webp and then have IT run the s3 sync?

    Or better yet just have webp express run it directly?

    This is part a.

    Part b is getting cloudfront rewrites properly. At the moment I’m trying to avoid needing something to rewrite url’s in the db (not use s3 upload).

    Any thought appreciated….

    @willstockstech @kevinxie @rosell-dk

    • This topic was modified 4 years, 4 months ago by chonkat.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter chonkat

    (@chonkat)

    This might not be the best way, but in case it is helpful, for part “b” above redirecting to clodfront I am using this in .htaccess:

    ————-
    RewriteCond %{HTTP_ACCEPT} image/webp
    RewriteCond %{REQUEST_FILENAME} (?i)(.*)(wp-content/uploads)(.*)(\.jpe?g|\.png)$ RewriteCond %1%2%3%4\.webp -f
    RewriteRule ^(.*)(\.jpe?g|\.png)$ https://mycdnsite.com/wp-content/uploads/$1$2\.webp [T=image/webp,E=EXISTING:1,E=ADDVARY:1,L,R=302]

    RewriteCond %{HTTP_ACCEPT} !image/webp
    RewriteCond %{REQUEST_FILENAME} (?i)(.*)(wp-content/uploads)(.*)(\.jpe?g|\.png)$
    RewriteRule ^(.*)(\.jpe?g|\.png)$ https://mycdnsite.com/wp-content/uploads/$1$2 [E=EXISTING:1,E=ADDVARY:1,L,R=302]

    ——————-

    I still need to put some time into part “a” above (sync from site to s3 when an image is uploaded). For now using “aws s3 sync”

    Thread Starter chonkat

    (@chonkat)

    updated aws sync to this:

    usr/local/bin/aws s3 sync –acl public-read /var/www/html/yoursite/wp-content/uploads/2020 s3://yourbucket/sh/wp-content/uploads/2020/ –expires “$(date -d ‘+6 months’ –utc +’%Y-%m-%dT%H:%M:%SZ’)” –cache-control ‘max-age=31104000’

    This is only for the 2020 folder. The copy to s3 script to use when copying to s3 right after uploading new images/converting with WebP Express will probably have less time.

    cache-control headers are important going in to the bucket.

    The header handling in the rest of .htaccess is from Web P Express, including the cache-control settings there.

    Part “c” will be avoiding ALL those redirects when doing it this way.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘web p express to s3’ is closed to new replies.