Distributing Static Content

To resolve issues of insufficient disk space when storing large amounts of static content and long load times, CMS developers have made it possible to integrate cloud storage with their own products.

These solutions offer numerous advantages:

  • storing large amounts of data in the cloud is typically cheaper than traditional storage options
  • by using cloud storage, you can effectively resolve problems with data availability: cloud services crash far less frequently than traditional servers
  • changing service providers no longer requires you manually migrate large amounts of data
  • CDNs significantly increase transfer speeds to users
  • since users download files from a CDN, server workloads are reduced
  • cloud service providers guarantee data durability: when data is uploaded to our Cloud Storage, it is immediately replicated on several independent servers and lost data is automatically restored

Wordpress Plugins

Selectel Storage Upload

Selectel Storage Upload was designed for synchronizing the files in a WordPress media library with Cloud Storage. The Selectel Storage Upload plugin can be installed either through the WordPress GUI (menu Plugins → Add New) or manually (download).

Once the Selectel Storage Upload plugin has been installed, it will be added to the list of available plugins. Activate the plugin to enable it.

To configure the plugin:

  1. Log into Cloud Storage and create a container for your media files.
  2. Create an additional user that will have access to the new container.
  3. In the WordPress menu, select SettingsSelectel Upload
  4. The following page will open
  5. Enter the username and password for the new user and the container name. The local path to media files and the authorization server URL are entered by default.
  6. Click Save Changes.

You can configure the plugin so that all files are uploaded immediately to storage, completely bypassing the WP media library. To do this, check the box next to Store files only in the Selectel Storage.

A domain can be mapped to the container where media is saved. In the field Full URL-path to files, enter the that domain (example: http://uploads.example.com).

You can also distribute files without binding a domain. In this case, enter the container address in the Full URL-path to files field (http://xxx.selcdn.com/name).

W3 Total Cache: Distributing Static Content over CDN

To accellerate and optimize your WordPress site, you can use any number of plugins, the most popular of which is W3 Total Cache. This can be used to set up static content distribution via CDN from our Cloud Storage.

After the plugin has been installed, check the configuration file.

Wp-config.php must contain the following line (if it is not there, you will have to add it manually):

/** Enable W3 Total Cache */
define('WP_CACHE', true); // Added by W3 Total Cache

The file .htacces should look as follows (if necessary, you’ll have to manually make the necessary changes):

#BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
	<IfModule mod_headers.c>
		Header append Vary User-Agent env=!dont-vary
	</IfModule>
	<IfModule mod_filter.c>
		AddOutputFilterByType DEFLATE text/css text/x-component application/x-j$
	<IfModule mod_mime.c>
		# DEFLATE by extension
		AddOutputFilter DEFLATE js css htm html xml
	</IfModule>
	</IfModule>
</IfModule>
# END W3TC Browser Cache
# BEGIN W3TC CDN
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
<IfModule mod_headers.c>
	Header set Access-Control-Allow-Origin "*"
</IfModule>
# END W3TC CDN

Save these changes and then configure the plugin.

  1. Find the Performance item in the main menu.
  2. Choose Performance → General Settings.
  3. On the new page, choose CDN.
  4. Check the box next to Enable.
  5. From the CDN Type list, select Self Hosted/File Transfer Protocol Upload:
  6. Save your changes.
  7. From the main menu, choose Performance → CDN.
  8. Scroll down to the section labeled Configuration:
  9. In the FTP hostname field, enter ftp.selcdn.ru. In the FTP username and FTP password fields, enter your Cloud Storage username and password (remember, when using FTP, it's better to create a separate user with limited access rights).
  10. For FTP path, enter the container name where your site's static files will be said. You will have to enter a slash in front of the container name (example: /mysite).
  11. In the Replace site's hostname with field, enter the canonical name that will be shown as the address of your uploaded files in place of ***.selcdn.com. When your site is loaded, image links will contain the CNAME and not the actual domain.

To make your site work even faster, you can make several CNAME records, which will each be attributed to a specific content type.

After these parameters have been entered, click Save all settings.

The folder /wp-content/upload will be automatically created inside your container. All static content will be stored here.

UpdraftPlus: Making Backups to the Cloud

UpdraftPlus is a simple and easy-to-use plugin for backing up WordPress sites with OpenStack Swift.

Before installing the plugin, you will have to make some preparations:

  • create a container in storage where you'll save your backups
  • create a special user with access to only this container
  • create a write-accessible folder for temporary backups in the wp-content directory on the server

Now install UpdraftPlus:

  1. From the Plugins menu, click Add New.
  2. After activating the plugin, UpdraftPlus Backups will be added to the Settings menu.
  3. Select this item and open the Settings tab.
  4. From the Choose your remote storage list, click OpenStack (Swift).
  5. In the Authentication URI field, enter https://auth.selcdn.ru.
  6. In the Tenant field, enter your account number.
  7. Enter the username and password of the additional user in the respective fields.
  8. In the Container field, enter the name of the container where you will store your backups.
  9. After entering all of these parameters, click Test OpenStack Settings.
  10. If the test is a success, a popup will open saying the plugin could access the container and create files.
  11. Scroll down to the Expert settings section and click Show expert settings.
  12. In the Backup directory field, enter the name of the previously created folder for saving your temporary backups.

The plugin is now ready.

Under the Settings tab, you can also select which files should be included in the backups and how often backups should be made.

After making all your changes, click Save Changes and click the tab Current Status.

To start the backup process, click Backup Now.

Data can be restored from a backup by clicking the Restore button.