Closed jaswrks closed 9 years ago
Hi,
I want to say that I've tried the CDN-Linker plugin with the Quick Cache and it mixes great. Maybe you can add its functionality to your plugin, I know that one of your competitor already does this. This is the CDN plugin - https://github.com/wmark/CDN-Linker
Alternatively you can just keep your plugin compatible with the CDN-Linker.
@Sboq Thank you very much for that info! I'll be working on this soon and will try to maintain support for that plugin as well.
One thing I noticed with the various CDN plugins (whether they use output buffering regex or not) is that they don't provide the ability to switch CDN URL's based on whether the current page is HTTP or HTTPS (SSL). This can become an issue if you're using a CNAME CDN (e.g., cdn.example.com), but also need to CDNify your HTTPS pages. If your SSL pages aren't pointing to a URL that has a valid security certificate, you'll get browser security errors.
For example, using the CloudFront CDN with origin pull, you'd have to use uglySubdomain.cloudfront.net for SSL pages, as the cdn.example.com CNAME wouldn't match the SSL certificate. Now, amazon does offer SSL CNAME certificates for around $600/month, but that's probably cost-prohibitive for a lot of folks. You could probably get it to work locally if you acquired a wildcard SSL certificate, but that's more expensive than a non-wildcard. So just using the ugly SSL CDN URL is the least expensive option.
What's interesting with Quick Cache implementing CDN support (SSL page or not) is that CDN URL conversion could be performed whether or not caching is being performed. For instance, if someone excludes certain pages from caching, it's probable that they'll still want their static files CDNified. So Quick Cache would be more of a hybrid plugin where the CDNification operates independently from the caching.
@raamdev I'm configuring a new site and I wonder should I install the existing CDN plugin or wait for your built-in with QC. It's not that I want to be pushy, I just wonder how fast this can be expected?
@Sboq I don't have any precise ETA, but it will be at least a few weeks before I have this feature integrated, tested, and ready for release.
@raamdev Well since you've decided to implement the CDN into the Quick Cache I have to say that I cheer for this feature to come fast because I'll have to reconfigure things later when it becomes available. The challenge would probably be with Multisite where QC is designed to be network active, while CDN plugin should be enabled and configured site by site. That's the reason the current situation with 2 separate plugins is working very well. I just wanted to remind you about this.
Edit: Maybe setting the CDN plugin to work like a plugin for the QC could be a good approach, then it's functionality can be accessed on a site by site basis.
@raamdev it's 2 months since the hint about the CDN addition. Is this feature any time close? Thanks.
@Sboq My apologies for the delay. I'm a bit behind on things, but this feature, along with Branched Cache Structure, are at the top of my list for new features that I'm working on for Quick Cache.
This code assumes that an S3 Bucket has been mounted locally, so it won't work unless a site owner can do that. Ideally, Quick Cache Pro could simplify this part further and make it easier for a novice site owner to set things up on their own.
@raamdev In my original feature request I noted the above.
I see there is an easy solution to this, which I will describe briefly...
Using the AWS-SDK (which we can redistribute w/ Quick Cache); we can add a stream wrapper like s3://[bucket]/uploads
. That would be (pretty much) the same as having an S3 bucket mounted locally, but in a much more compatible way that can be accomplished via PHP code alone.
See: http://docs.aws.amazon.com/aws-sdk-php/guide/latest/feature-s3-stream-wrapper.html
So with that in place... the example I posted earlier might look like this...
<?php
require_once 'aws.phar';
use Aws\S3\S3Client;
add_action('init', 'cdn::init');
add_filter('pre_option_upload_path', 'cdn::uploads_path');
add_filter('pre_option_upload_url_path', 'cdn::uploads_url_path');
class cdn // Content delivery network for this site.
{
public static function init()
{
$client = S3Client::factory(array(
'key' => '<aws access key>',
'secret' => '<aws secret key>'
));
$client->registerStreamWrapper(); // Register `s3://` stream wrapper.
}
public static function uploads_path()
{
return 's3://[bucket]/uploads';
// Files uploaded through the WP Media Library go here.
}
public static function uploads_url_path()
{
return 'http://d1v41qemfjie0l.cloudfront.net/';
// Files served by WordPress that reside in my `upload_path`; are served with this URL as the base.
}
}
@raamdev The AWS-SDK can be downloaded here. http://aws.amazon.com/sdkforphp/
@JasWSInc Perfect! Thanks so much. I'll work on getting this integrated so that we can start testing it for a future release.
@raamdev I just ran some tests against the S3 stream wrapper in my work on another project. There are two issues that I ran into which I thought I would share with you here.
The WordPress filters I mentioned previously in this topic: pre_option_upload_path
and pre_option_upload_url_path
; will NOT work with an s3://
stream wrapper.
WP forces an ABSPATH
prefix on the values. So this won't work because you will end up with /abs/path/to/wordpress/s3://bucket/uploads
. Not good.
The solution is to filter the entire array of data that WP uses. See filter upload_dir
here: https://github.com/WordPress/WordPress/blob/master/wp-includes/functions.php#L1658
A quick example...
add_filter('upload_dir', 'cdn::upload_dir');
class cdn // Content delivery network for this site.
{
public static function upload_dir($details)
{
$details['basedir'] = 's3://[BUCKET]/uploads';
$details['path'] = $details['basedir'].$details['subdir'];
$details['baseurl'] = 'http://d1v41qemfjie0l.cloudfront.net/uploads';
$details['url'] = $details['baseurl'].$details['subdir'];
return $details; // After CDN filters.
}
}
You MUST use the latest release of the AWS-SDK. I was testing this the other day and ran into a major limitation in the S3 stream wrapper related to mkdir()
not working properly. I contacted AWS and they've had the issue corrected in the latest release (available today).
@JasWSInc Thanks! That will definitely come in handy when I tackle CDN support. I'm currently working on #3.
+! on CDN. I use CDN-Linker and its great, but if we can combine that with S3 support for the cache files... AMAZING!!
Adding this to the Future Release milestone to work on next, after the Next Release.
Also requested here: http://wordpress.org/support/topic/cdn-support?replies=1
Punting to Future Release milestone so that the bugs in the Next Release milestone can be released sooner rather than later. CDN integration will be my top priority feature to work on for the following release.
Not sure if my comment showed up.
Two questions for you:
Thanks!
Is this CDN feature going to be as good as W3 Total Cache's CDN with MaxCDN? I intend to use it with MaxCDN.
Yes.
Will Quick Cache & the CDN feature be fully compatible with s2Member and iDevAffiliate? (because W3 Total Cache is not 100% compatible with both)
Yes. It will be fully compatible with s2Member and iDevAffiliate.
Raam you're going to make me cry bro. Lol, I'm so excited. Now I can finally get rid of W3 Total Cache! Weeee!
:crying_cat_face: : I am already there. Tears of happiness brother. I can't wait!
Very excited here on this as well...
But to completely replace other (bloated) caching plugins, would need #47 too!! (Just a little plug and reminder!! :))))
@raamdev @jaswsinc Holy moly, DreamSpeed CDN (Part of DreamObjects) just came out! Can you please make sure your release (I'm assuming is on the 19th) is compatible with this as well!! It's much better than MaxCDN so we're going to be switching over to it and I really want to delete as many plugins as I'm using as possible so we're only using WebSharks products and iDevAffiliate. Here's the link: https://www.dreamhost.com/cloud/cdn/ Thank you!! And here's a wiki on it http://wiki.dreamhost.com/DreamSpeed_CDN_Overview
What is the intention for Quick Cache CDN integration? @jaswsinc your initial comment when you opened this feature request indicated the following:
I would like to be able to serve WordPress media from a CDN of my choosing. For instance, so I can cache static media at edge locations with CloudFront.
But "static media" here implies only media uploaded through the WordPress Media Library, correct?
There are lots of ways Quick Cache could utilize CDN integration:
wp-includes/*
)wp-content/themes/<active-theme>/*
)I feel that it would be nice to eventually support all of these, but obviously that will take some time, planning, and testing. I'm thinking it will make sense to start with CDN support for hosting attachments (files uploaded through the Media Library) and then work on the other features, maybe in the order listed above.
Thoughts?
@raamdev I'm going to respond to this privately and share my thoughts about what we could do here.
Referencing: https://github.com/MaxCDN/php-maxcdn Also referencing: https://docs.maxcdn.com/
Referencing: http://docs.aws.amazon.com/AmazonCloudFront/latest/APIReference/Welcome.html Also referencing: http://docs.aws.amazon.com/aws-sdk-php/guide/latest/installation.html Also referencing: http://docs.aws.amazon.com/aws-sdk-php/latest/ Creating a distro: http://amzn.to/1opSyYJ
Quick update: This branch of QCP now contains a composer.json
file. When we work on this repo locally we'll need to remember to run cd quick-cache-pro/quick-cache-pro && composer install
to install the MaxCDN SDK and AWS SDK dependencies that I've added as part of the work on this issue.
If you don't have Composer, you can get this via Homebrew or Mac Ports (I think).
Another option, is that I could just push the vendor
directory that I have locally into this repo. There are MANY files in that directory installed via Composer, but that would put everything (except the sub-modules for the HTML Compressor) into the repo for QCP.
I'm going to leave this issue as-is for now. That way @raamdev can have a chance to review what's been added thus far. Maybe we could chat about this a little also and see how we might want to proceed.
quick-cache-pro/submodules/aws-php-sdk
quick-cache-pro/submodules/maxcdn-php-sdk
htmlc
submodule to quick-cache-pro/submodules/html-compressor
Great to see the progress on this! Keeping an eye out. I switched from dreamhost to inmotion hosting because they have SSD drives and you can definitely tell the difference. All I need to make my site complete now is quick cache with MaxCDN :-)! Weeeee!!! Hopefully it works similar to how W3TC works where it caches as much as possible in the wp-content folder and elsewhere with options to not cache the directories or files of your choice.
content_filter()
in the cdn_base
class.cdn_base::local_file()
.The URL/content filtering phase of this project has been completed. A first pass anyway. Further testing will be necessary once the CDN integration is closer to completion overall, but I feel good about the content/URL filtering portion of it for now.
create_distro()
method for CloudFront.get_distro()
method for CloudFront.update_distro()
method for CloudFront.create_distro()
method for MaxCDN.get_distro()
method for MaxCDN.update_distro()
method for MaxCDN.+1 for CDN support :) I was actually trying to use both QuickCache and each one of its 2 competitors (with caching disabled, just the CDN feature enabled) together in order to have the "CDN Rewrite" feature, but with no luck... supercache's cdn feature doesn't work at all when its caching feature is disabled, and w3tc works great with cdn enabled and caching disabled - but it also completely disables/overrides QuickCache...
Basically I already have a cdn domain (I'm using it as a subdomain: cdn.domain.com) and all I'm looking for the the "url rewrite" feature that will point static files in wp-content and wp-include from domain.com to cdn.domain.com . Please make sure to include this "generic mirror" CDN mode
Hope to see this feature in QuickCache Pro soon...
Thanks!
Hey @jaswsinc @raamdev will the price of Quick Cache go up with the CDN release? Thank you.
@ioerjfoige0439i I'd say that is likely, yes. A bit, anyway :-)
TODO:
@jaswsinc @raamdev Okay but what if you've already paid for the $15 license? We still have to pay more money to upgrade?
@ioerjfoige0439i It's too early to say for sure, but there are no plans to do this at the moment :-)
@jaswsinc @raamdev Okay nice! I'll make sure to tell my customers to go buy the $15 license right now then so they don't have to pay more later. Thanks!
+1 for the CDN-Linker plugin - works great together with QC Pro.
+1 for CNAME CDN support (e.g., cdn.example.com) or CDN-Linker plugin comaptibility
Any updates guys? Here's the TRIFECTA pictured above: Quick Cache / Zen Cache perfectly integrated with: s2Member iDevAffiliate MaxCDN
Let me know your thoughts on my above Trifecta @clavaque @raamdev @BruceCaldwell @jaswsinc @ethanpil @Reedyseth I think this would be the dream for all owners of Quick Cache / Zen Cache.
iDevAffiliate works with s2Member now already but unfortunately, iDevAffiliate and s2Member don't work together properly when W3 Total Cache is turned on, but W3 Total Cache does MaxCDN perfectly. If W3 Total Cache worked properly with iDevAffiliate and s2Member then I would just use it instead because all that's missing is MaxCDN. If Quick Cache / Zen Cache could work nicely and fully tested together with all 3 then that would eliminate our need for W3 Total Cache completely and allow everyone to see the full potential of all these technologies working together!
Of course being that iDevAffiliate has it's own seperate install folder, but just that it can properly communicate with s2Member when Quick Cache / Zen Cache is turned on and connected to MaxCDN. iDevAffiliate would not need to be using any CDN features because it is pretty lite weight ( I mean unless you wanted to do that in the future but for right now that's not very important ).
@ioerjfoige0439i thank you for the ideas and the suggestions. :)
We already have plans to launch ZenCache with MaxCDN support within the next few weeks / early January. We'll ensure that ZenCache + s2Member + iDevAffiliate work together as expected!
@raamdev I'd like to request the following feature in QC Pro.
Here is a clip from a custom plugin that I've used for quite awhile now. Perhaps it could serve as a starting point for a whole new set of functionality that's offered by QC Pro when it comes to CDNs.
This code assumes that an S3 Bucket has been mounted locally, so it won't work unless a site owner can do that. Ideally, Quick Cache Pro could simplify this part further and make it easier for a novice site owner to set things up on their own.
Other Considerations...
It's probably worth having a discussion about how far QC Pro is going to take it's CDN integration — if and when it's added as a pro feature.
The feature request here only asks for the Media Library. However, there are plugins like CloudFlare that deal with ALL static files served by WordPress, which is even better IMO.
A QC user recently wrote...
TODOs
quick-cache-pro/submodules/aws-php-sdk
quick-cache-pro/submodules/maxcdn-php-sdk
htmlc
submodule toquick-cache-pro/submodules/html-compressor
content_filter()
in thecdn_base
class.cdn_base::local_file()
.create_distro()
method for CloudFront.get_distro()
method for CloudFront.update_distro()
method for CloudFront.create_distro()
method for MaxCDN.get_distro()
method for MaxCDN.update_distro()
method for MaxCDN.