WordPress.org

Ready to get started?Download WordPress

Forums

CDN Sync Tool
Upload location is centralized on MultiSite (10 posts)

  1. Ryan Willis
    Member
    Posted 3 years ago #

    When using this plugin on a multisite install with CloudFront, all files are uploaded to the files/ directory regardless of which blog they belong to. This could cause issues with files from one blog overwriting another, or a user made unable to upload files because they already exist. Are there plans to fix this?

    Also, I noticed the site still uses the blog url rather than the CDN url when displaying content in posts/pages (though the js and css url are pointed at the CDN via the super cache plugin). Is there a reason for this?

  2. Backie
    Member
    Plugin Contributor

    Posted 3 years ago #

    Well the reason they are put in the files/ folder is because that's where WordPress rewrites the url to. Changing it so that it would upload to files/{$blog_ID} would mean that the url rewriting system would have to be changed. However you can just create another bucket and CloudFront distrubtion instance for each blog site. Which will pretty much cost the same as having them all in one bucket.

    Can you provide a link to show me where it's using the blog url instead of the CDN url?

    Thanks

  3. Ryan Willis
    Member
    Posted 3 years ago #

    Creating a separate bucket for each site would cause redundant copies of the wordpress theme and plugin files as well, which would cost more. I'll probably have to stick with appending the blog id to the path for now.

    As for the url rewrite, I'd be happy to send a link but this installation is not currently live. Do I need to add "files" to the rewrite rules on the CDN tab in the WP Super Cache configuration? Or is it handled by the plugin automatically?

    Thanks for your help.

  4. Ryan Willis
    Member
    Posted 3 years ago #

    Adding "files" to the rewrite matches in the WP Super Cache config did the trick for replacing the hostname. Now I just need to figure out how to add the blog ID to the rewrite. I'll take a look at the OSSDL CDN Off-linker source, but do you have any ideas?

  5. Backie
    Member
    Plugin Contributor

    Posted 3 years ago #

    Well I'll have a look into it tomorrow. However I suspect it'll be more hassle than 2-3 US cents a month is worth but if there is a quick and easy way to achieve it'll implement it.

  6. Ryan Willis
    Member
    Posted 3 years ago #

    Right on. For the time being, I've added an additional str_replace to OSSDL's rewriter function. Seems to work, but obviously a solution that doesn't require modifying plugin files (that will be overwritten after each update) would be better, heh.

    Excellent work on this plugin btw :)

  7. davidljung
    Member
    Posted 3 years ago #

    I've also installed CDN Sync Tool with the aim of using it for multisite. I discovered the hard way that it isn't really multisite aware.
    Tomorrow I have to start creating 312 sites, which will require some automation. While it would be possible to script creation of 312 S3 buckets & CloudFront distributions, I don't think I'm going to do that (and wouldn't like having to login to each site to click the plugin sync button anyway).

    Unfortunately, until this plugin can work at the network level, instead of at the site level, I can't use it in practice.

    If anyone knows of a multisite aware CDN plugin, please let me know.

    Otherwise it looks like a nice plugin for a handful of sites.

    Cheers.

  8. Backie
    Member
    Plugin Contributor

    Posted 3 years ago #

    Well don't know where you see the plugin not being multisite aware? This would imply it would upload the wp-content/upload directory content when it should be uploading the contents of a blogs.dir/2/files. Which it doesn't do, it uploads the content of blogs.dir/2/files and instead of putting it in the absolute path it puts it in the files directory since that's where WordPress expects the browser to be able to find them and that to disclose the site id is generally considered as information disclosure and frowned upon in the security community.

    Since you're doing an automated install for 312 sites, I can safely assume you were hired for the job because you know what your doing? So editing the install script to leverage the aws sdk and this plugin shouldn't be hard for you?

    As stated the plugin can work at the network level. I am sorry you feel that the plugin doesn't do what you want, you can always fork the plugin and change the features to do what you want. We have released it under the GPL v2 license. If you want to fork it you can always use github to achieve this https://github.com/icambridge/Cdn-Sync-Tool.

    Yes I do know a multisite aware CDN plugin - it's called CDN Sync Tool! There is also W3 Total Cache.

  9. davidljung
    Member
    Posted 3 years ago #

    ok, so the plugin is multisite aware in the sense that it uses blogs.dir/2/files etc. I didn't realize that. However, the configuration settings need to be setup independently for each site. While I can see some people may like that flexibility, ideally it would also have the ability to be setup once for all network sites. Obviously, using the admin form fields to setup hundreds of sites manually is impractical.

    I wasn't hired specifically for this job, no, but I am an employee. I chose to use WordPress even though I'm not familiar with it, since the code base seems relatively small, simple and clean. I am familiar with cloud services and AWS (though mainly from the Java world, I have written several PHP apps that use S3/CloudFront/SimpleDB).
    So, I could modify the plugin to automate all the necessary pieces, but I honestly don't want to generate 312 S3 buckets and 312 CloudFront distributions when one would do perfectly fine.

    Yes, I could always fork the code - but this is why Linux has never gained wide acceptance in the general public - because it is a bunch of pieces being developed by people serving their own interests, typically without serving the greater community (i.e. the public). Even when some organization stands-up and tries to take on that role for those who want it, the rest of the self-interested project communities shout them down (cf Ubuntu).

    So, no, I won't fork CDN Sync Tool if I can avoid it. What I may do, is look more closely at the code for both CDN Sync Tool and any other similar plugins and decide which is easiest to adapt to my requirements, then contribute any code I write back.

    Thanks for the pointer.
    Cheers,
    -David.

  10. Backie
    Member
    Plugin Contributor

    Posted 3 years ago #

    Just re-read my message and noticed I seem rather rude, so my bad on that front. However I come baring gifts.

    Half way through typing how easy it should be to add a hack to do it, I figured there is no good reason not to. So https://github.com/icambridge/cdn-sync-tool now contains the ability to have the absolute urls when syncing and includes a filter on wpsupercache_buffer to change the /files/ to /wp-content/blogs.dir/{$blog_id}/files/ though you'll still need to sync them which should be in the automated install script however that should be pretty easy.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic