print page  |  view normal version 

Set up a CDN

Enano releases 1.1.5 and later include support for a CDN, or Content Delivery Network. Using a CDN can significantly improve the speed of your site.

What is a CDN?

Simply put, a CDN is a separate server on a separate network that hosts only static files such as images and CSS. Modern CDNs often consist of globally distributed networks, with geolocation technology built into their DNS servers, allowing automatic selection of a server that is geographically close to the user.

Using a CDN decreases network latency and lets aesthetic elements of pages load faster than they would if everything was hosted on the same server. Moreover, since the user can open many connections to the CDN server and only one or two to the Enano server, parallel downloads can greatly enhance the loading speed of pages.

Configuring Enano to use a CDN

Setting Enano up to use a CDN requires a bit of effort because it involves uploading Enano files to a different server. Once these files are uploaded, pointing Enano to the CDN server is easy.

Uploading the files

To set up Enano for CDN use, you need to take several of the directories within Enano's installation root and upload them to your CDN server. These directories are:

  • images/
  • themes/ (You won't need to upload .tpl files, but it won't hurt if they're on your CDN anyway. If you don't want people to have access to your theme, delete .tpl files.)
  • includes/clientside/

The last directory has a special case. Enano's Javascript code is rather large because of all of the AJAX functionality and visual effects. Therefore, "minifying" or compressing the Enano Javascript library will give you a significant performance improvement over just uploading the static Javascript files.

Enano provides an easy way to quickly compress all of its runtime files if you have a command-line (CLI) version of PHP installed. To use Enano's Javascript compressor:

  • Ensure that Enano is installed and working properly on your web server
  • Open a shell or command prompt window on your server. Linux and Unix hosting services will usually allow you to do this with SSH. Windows servers will likely use Remote Desktop.
  • Use the cd command to navigate to your Enano installation directory
  • Change to the /includes/clientside directory within your Enano root
  • Type: php jscompress.php

Since the jscompress.php script requires database access in order to use caching and site configuration features, your shell server (if different from your web server, like on SourceForge.net) needs to have access to your database server. This usually isn't a problem if everything is consolidated onto one host, but if your webhost uses a more distributed approach you may need to adjust your config.php. Contact your host if you get any errors connecting to the database from the command line.

If everything checks out, the script will create a file called enano-lib.zip in the /includes/clientside/ directory. You should download and unzip that file, and then upload all of its contents to your CDN server into includes/clientside/static/, replacing any existing files.

If you can't manage to get enano-lib.zip to generate, feel free to ask someone in the Enano IRC channel to generate a copy for you. Be sure to tell us your Enano version so we can generate the right version of the Javascript runtime for you.

Configuring Enano

After double-checking to make sure your files are all in the right places, configure Enano so that your CDN server will be used. Open the administration panel and go to General → General Configuration. Find the setting for "URL to CDN server" and enter in the base URL to your CDN This URL will be used as the prefix for all CDN URLs.

For example, if your CDN server is cdn.foobarinc.com and the Enano directories images, includes, and themes are in /enano/1.1.5/, you would enter http://cdn.foobarinc.com/enano/1.1.5. Note that any trailing slashes will be removed.

When you're finished entering the URL, press Enter or click Save Changes at the bottom of the General Configuration page.

You're done!

Now instead of loading images and scripts from the Enano server, Enano will use your CDN, giving your users a much faster browsing experience. To test your new CDN configuration, use your browser's view source option to search around for your CDN URL in the page source. Almost every theme will use your CDN URL in at least one place.

Theme support

You'll get the most benefit from your CDN if your theme fully supports the new CDN-related template variables. All of the themes that come with Enano are kept up-to-date; if you're using a theme that isn't bundled with a default Enano distribution, contact the author of the theme with a link to this page.

Theme developers: You can make your themes support Enano's CDN feature by changing image and CSS references from using {SCRIPTPATH} to using {CDNPATH}. We're planning to add the CDNPATH variable to Enano 1.0.x for compatibility as well. Note that if CDN support is disabled in the site configuration, the CDNPATH variable will be the same as SCRIPTPATH.

© 2007 Contributors. All content is under the GNU Free Documentation License.
Powered by Enano | Valid XHTML 1.1 | Valid CSS | Time: 0.06s