Gallery files and CDN
-
I found that gallery files aren’t uploaded to CDN automatically (I’m using CloudFront over S3 option). There is need to add a hook manually?
In custom files list I have added
{wp_content_dir}/gallery/* {wp_content_dir}/gallery/*.jpg {wp_content_dir}/gallery/*.png
-
Hello @bublick
Thank you for your inquiry and I am happy to assist you with this.
Can you please share if the option “Only Purge CDN manually” is enabled in Performance>CDN and if so have you tried purging the CDN completely and see if the files are getting uploaded?
Thanks!Thank you @vmarko for reply.
After purging and waiting some time it won’t appear. It will appear if I upload all custom files using Performance>CDN. But new uploaded images won’t be uploaded to CDN automatically.
So, to clarify this. If I upload image to WordPress’ native media gallery it will be uploaded to cdn automatically. The problem is only with custom files
Hello @bublick
Can you please specify how you are uploading those files in Performance>CDN?
And again is the option “Only Purge CDN manually” enabled?Thanks!
Can you please specify how you are uploading those files in Performance>CDN?
I’m using this button (https://i.imgur.com/1sWKqDd.png)
And again is the option “Only Purge CDN manually” enabled?
I’ve disabled it because images stopped to upload to cdn, even from native WordPress media gallery. Images from galleries too
Hello @bublick
Thank you for the information. As you mentioned you are using the CDN Push type. This means that those custom files need to be uploaded manually since it’s not a “native” folder.
As for the “Only Purge CDN manually” option, Please note that that option is there due to the huge bills on AWS caused by invalidations.
Cloudflare doesn’t charge for “request”, but for invalidation path.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#PayingForInvalidation
The first 1,000 invalidation paths that you submit per month are free; you pay for each invalidation path over 1,000 in a month. An invalidation path can be for a single file (such as /images/logo.jpg) or for multiple files (such as /images/*). A path that includes the * wildcard counts as one path even if it causes CloudFront to invalidate thousands of files.
SO to avoid invalidations you should upload custom files manually.
Thanks!Thank you @vmarko. Seems I got you. This project is built such way, because there is production, staging and staging-dev instances. With a common S3 bucket. So, posts are written on staging node and images are uploaded on staging node too. Right now I’m working on staging-dev. So, all invalidate issues will be catched before too many requests will be proceeded.
Anyway. Is there any way to call that button from code? Or upload to CloudFront only specified image. I think I can
add_action()to call this one after image is uploaded to the gallery.Thank you
Hello @bublick
Thank you for the info. I am glad we are on the same page.
Please check wp-content/plugins/w3-total-cache/Cdn_AdminActions.php#L256* CDN export action * * @return void */ function w3tc_cdn_export() { $w3_plugin_cdn = Dispatcher::component( 'Cdn_Plugin' ); $cdn_export_type = Util_Request::get_string( 'cdn_export_type', 'custom' ); switch ( $cdn_export_type ) { case 'includes': $title = __( 'Includes files export', 'w3-total-cache' ); $files = $w3_plugin_cdn->get_files_includes(); break; case 'theme': $title = __( 'Theme files export', 'w3-total-cache' ); $files = $w3_plugin_cdn->get_files_theme(); break; case 'minify': $title = __( 'Minify files export', 'w3-total-cache' ); $files = $w3_plugin_cdn->get_files_minify(); break; default: case 'custom': $title = __( 'Custom files export', 'w3-total-cache' ); $files = $w3_plugin_cdn->get_files_custom(); break; } include W3TC_INC_DIR . '/popup/cdn_export_file.php';This may help you with your use case.
Thanks!
The topic ‘Gallery files and CDN’ is closed to new replies.