Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Menno van der Sman committed Oct 2, 2010
1 parent ca0dc25 commit ff32d95
Showing 1 changed file with 54 additions and 15 deletions.
69 changes: 54 additions & 15 deletions README.markdown
Expand Up @@ -12,7 +12,7 @@ The best way to expire your assets on CloudFront is to upload the asset to a new

### Efficient uploading

By using the MD5-hash we can easily determined which assets aren't uploaded yet. This speeds up the deployment considerably.
By using the MD5-hash we can easily determine which assets aren't uploaded yet. This speeds up the deployment considerably.

### Compressed assets

Expand All @@ -22,21 +22,21 @@ CloudFront will not serve compressed assets automatically. To counter this, the

gem install cloudfront_asset_host

Include the gem in your app's `environment.rb` or `Gemfile`.
Add the gem to your `environment.rb` or `Gemfile`.

### Dependencies

The gem relies on `gzip` utility. Make sure it is available locally and on your servers.
The gem relies on the `gzip` utility. Make sure it is available locally.

### Configuration

Make sure your s3-credentials are stored in _config/s3.yml_ like this:

access_key_id: 'access_key'
secret_access_key: 'secret'

or with environment specified:

production:
access_key_id: 'access_key'
secret_access_key: 'secret'
Expand All @@ -52,10 +52,17 @@ Create an initializer to configure the plugin _config/initializers/cloudfront_as
# Extended configuration
CloudfrontAssetHost.configure do |config|
config.bucket = "bucketname" # required
config.cname = "assets.domain.com" # if you have a cname configured for your distribution or bucket
config.key_prefix = "app/" # if you share the bucket and want to keep things separated
config.plain_prefix = "" # prefix for paths to uncompressed files
config.s3_config = "#{RAILS_ROOT}/config/s3.yml" # Alternative location of your s3-config file
config.cname = "assets.domain.com" # cname configured for your distribution or bucket

config.key_prefix = "app/" # prefix for paths
config.plain_prefix = "" # prefix for paths to uncompressed files

config.asset_dirs = %w(images flash) # specify directories to be uploaded
config.exclude_pattern = /pdf/ # exclude matching assets from uploading

# s3 configuration
config.s3_config = "path/to/s3.yml" # Alternative location of your s3-config file
config.s3_logging = true # enable logging for this bucket

# gzip related configuration
config.gzip = true # enable gzipped assets (defaults to true)
Expand All @@ -64,30 +71,62 @@ Create an initializer to configure the plugin _config/initializers/cloudfront_as

config.enabled = true if Rails.env.production? # only enable in production
end
The _cname_ config options also accepts Proc or string with the "%d" parameter (e.g. "http://assets%d.example.com" for multiple hosts).

The _cname_ option also accepts a `Proc` or `String` with the `%d` parameter (e.g. "assets%d.example.com" for multiple hosts).

## Usage

### Uploading your assets
Run `CloudfrontAssetHost::Uploader.upload!(:verbose => true, :dryrun => false)` before your deployment. Put it for example in your Rakefile or capistrano-recipe. Verbose output will include information about which keys are being uploaded. Enabling _dryrun_ will skip the actual upload if you're just interested to see what will be uploaded.
Run `CloudfrontAssetHost::Uploader.upload!(:verbose => true, :dryrun => false)` before your deployment. Put it for example in your Rakefile or Capistrano-recipe. Verbose output will include information about which keys are being uploaded. Enabling _dryrun_ will skip the actual upload if you're just interested to see what will be uploaded.

### Hooks
If the plugin is enabled. Rails' internal `asset_host` and `asset_id` functionality will be overridden to point to the location of the assets on Cloudfront.

### Other plugins
When using in combination with SASS and/or asset_packager it is recommended to generate the css-files and package your assets before uploading them to Cloudfront. For example, call `Sass::Plugin.update_stylesheets` and `Synthesis::AssetPackage.build_all` first.
When using in combination with SASS and/or asset_packager it is recommended to generate the css files and package your assets before uploading them to Cloudfront. For example, call `Sass::Plugin.update_stylesheets` and `Synthesis::AssetPackage.build_all` first.

## Changelog

- 1.1
- New features:
- Add support for CNAME-interpolation [wpeterson]
- Add ability to specify an exclude regex for CDN content [wpeterson]
- Configure directories to upload through CloudfrontAssetHost.asset_dirs [wpeterson]
- CloudfrontAssetHost.cname accepts Proc [foresth]
- Rewrite all css-files when some images are modified [foresth]
- Enable S3-logging with CloudfrontAssetHost.s3_loggin (defaults to false) [foresth]
- Ability to insert prefix to paths to uncompressed files [foresth]
- Ability to define environment specific credentials in s3.yml [foresth]

- Fixes and improvements:
- Strip query-parameters from image-urls in CSS [wpeterson]
- Use Digest::MD5 as md5-implementation [wpeterson, mattdb, foresth]
- Fix bug working with paths with spaces [caleb]

- 1.0.2
- Fix bug serving gzipped-assets to IE

- 1.0.1
- First release

## Contributing

Feel free to fork the project and send pull-requests.
Feel free to fork the project and send pull requests.

## Contributors

Thanks to these people who contributed patches:

* [Winfield](http://github.com/wpeterson)
* [Caleb Land](http://github.com/caleb)
* [foresth](http://github.com/foresth)

## Compatibility

Tested on Rails 2.3.5 with SASS and AssetPackager plugins

## Copyright

Created at Wakoopa
Created at [Wakoopa](http://wakoopa.com)

Copyright (c) 2010 Menno van der Sman, released under the MIT license

0 comments on commit ff32d95

Please sign in to comment.