Offload Media to CDN
To offload media to a CDN, Please Send a ticket to SRE team to initiate the process of uploading media to the R2 Cloud.
Official SRE Ticketing link : https://august99.atlassian.net/servicedesk/customer/portal/3 .
Start offloading media database point to cdn
Add entries to wp_as3cf_items
table
Within your project directory, make a temporary file and copy snippet below (offload.sql
). Do not commit this file
- Replace
<region>
with s3 bucket region. - Replace
<bucket>
with s3 bucket name. - Replace all
<project_slug>
with your project slug.
Import using wp cli:
terminal
wp db import offload.sql
Check
wp_as3cf_items
table entries to have the correct paths.
offload.sql
INSERT IGNORE INTO wp_as3cf_items (
provider,
region,
bucket,
path,
original_path,
is_private,
source_type,
source_id,
source_path,
original_source_path,
extra_info,
originator,
is_verified
)
SELECT
'aws',
'<region>',
'<bucket>',
concat('<project_slug>/', pm.meta_value) AS path,
concat('<project_slug>/', pm.meta_value) AS original_path,
0,
'media-library',
p.id AS source_id,
pm.meta_value AS source_path,
pm.meta_value AS original_source_path,
'a:2:{s:13:"private_sizes";a:0:{}s:14:"private_prefix";s:0:"";}',
0,
1
FROM
`wp_posts` p
LEFT JOIN `wp_postmeta` pm ON pm.post_id = p.id AND pm.meta_key = '_wp_attached_file'
WHERE
p.post_type = 'attachment';
Once the SRE team has uploaded the media to the R2 Cloud, images will be served from the CDN. You can verify this by checking the URLs of your media files in the WordPress admin area or by inspecting the source code of your site.
Last updated on