Knowledge base
How to use OCS for serving static files in sites based on WordPress and W3 Total Cache plugin?
Posted by Pomoc Oktawave on 29.10.2014 21:10

To configure Wordpress to use OCS, a package php5-curl must be on instance with WP:


apt-get install php-curl


In Settings | Permalinks select the type of permalinks, and then install in Wordpress a plugin called W3 Total Cache, but don't turn it on.

We must modify the W3 Total Cache plugin, by introducing the following changes.


<                 if (preg_match('~^([a-z0-9\-\.]*)~i', $_domain, $matches)) {
>                 if (preg_match('~^([a-z0-9\-\.\_]*)~i', $_domain, $matches)) {

>           case 'pl':
>               $host = PL_AUTHURL;
>               break;

> define("PL_AUTHURL", "");
<         if ($status != 204) {
>         if ($status != 204 && $status != 200) {

> <option value="pl"<?php echo selected($this->_config->get_string('cdn.rscf.location'),
 'pl'); ?>>PL</option>


Now we can turn on W3 Total Cache plugin.

Then, in the Performance | General Settings | CDN tab, choose CDN Type | Rackspace Cloud Files and save the changes.

Go to Performance | CDN and enter the following configuration:

  • As the username give the full name of OCS, for example. NameSurname1234:user.
  • As an API key, give the password of the OCS user.
  • Select Location | PL.
  • In Container field, enter the name of a previously created container.
  • SSL support set to Auto.
  • In the field Replace site's hostname type in the adress from where the files will be available, to upload into the OCS. It can be eg. in the form of <container>.<Auth_token> You can also set CNAME record earlier for your domain, which redirects to the container and give it at this point.
  • You can verify the settings are correct by clicking Test Cloud Files upload.
  • From wp-includes file types to upload and Theme file types to upload remove entries for files with extensions *.css and *.js. Modified default values ​​for these fields are as follows:
  1.      wp-includes file types to upload: *.gif; *.png; *.jpg; *.xml
  2.      Theme file types to upload: *.gif; *.Png; *.Jpg; *.Ico; *.Ttf, *.Otf *.WOFF, *.Less

In the Performance | General Settings | CDN you can now Enable and save the changes. From now on all files added to the Wordpress media library will be uploaded to the OCS, including links to these files will be carried out at the address listed previously in section above.

After you verify that everything is working properly using the options in Performance | CDN | General we can transfer to the OCS other static elements of our service, for example. the media and attachments, which were placed on website before, elements of graphic motif, etc.

Files made ​​available from the OCS are also stored in the traditional way on instance, and are not removed automatically, but you can add to the cron entry that will remove files from the disk for us. If needed, there will always be possible to recover them from the OCS service.

(0 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below. This is required to prevent automated registrations and form submissions.