cloudfront_asset_host 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +34 -7
- data/VERSION +1 -1
- data/cloudfront_asset_host.gemspec +1 -1
- metadata +2 -2
data/README.markdown
CHANGED
@@ -1,21 +1,40 @@
|
|
1
1
|
# CloudFront AssetHost
|
2
2
|
|
3
|
-
Easy deployment of your assets on CloudFront or S3. When enabled in production, your assets will be served from
|
3
|
+
Easy deployment of your assets on CloudFront or S3. When enabled in production, your assets will be served from CloudFront/S3 which will result in a speedier front-end.
|
4
|
+
|
5
|
+
## Why?
|
6
|
+
|
7
|
+
Hosting your assets on CloudFront ensures minimum latency for all your visitors. But deploying your assets requires some additional management that this gem provides.
|
8
|
+
|
9
|
+
### Expiration
|
10
|
+
|
11
|
+
The best way to expire your assets on CloudFront is to upload the asset to a new unique url. The gem will calculate the MD5-hash of the asset and incorporate that into the URL.
|
12
|
+
|
13
|
+
### Efficient uploading
|
14
|
+
|
15
|
+
By using the MD5-hash we can easily determined which assets aren't uploaded yet. This speeds up the deployment considerably.
|
16
|
+
|
17
|
+
### Compressed assets
|
18
|
+
|
19
|
+
CloudFront will not serve compressed assets automatically. To counter this, the gem will upload gzipped javascripts and stylesheets and serve them when the user-agent supports it.
|
4
20
|
|
5
21
|
## Installing
|
6
22
|
|
7
|
-
|
23
|
+
gem install cloudfront_asset_host
|
24
|
+
|
25
|
+
Include the gem in your app's `environment.rb` or `Gemfile`.
|
8
26
|
|
9
27
|
### Dependencies
|
10
28
|
|
29
|
+
The gem relies on `openssl md5` and `gzip` utilities. Make sure they are available locally and on your servers.
|
30
|
+
|
31
|
+
### Configuration
|
32
|
+
|
11
33
|
Make sure your s3-credentials are stored in _config/s3.yml_ like this:
|
12
34
|
|
13
35
|
access_key_id: 'access_key'
|
14
36
|
secret_access_key: 'secret'
|
15
37
|
|
16
|
-
The gem relies on +openssl md5+ and +gzip+ utilities. Make sure they are available locally and on your servers.
|
17
|
-
|
18
|
-
### Configuration
|
19
38
|
Create an initializer to configure the plugin _config/initializers/cloudfront_asset_host.rb_
|
20
39
|
|
21
40
|
# Simple configuration
|
@@ -32,11 +51,11 @@ Create an initializer to configure the plugin _config/initializers/cloudfront_as
|
|
32
51
|
config.s3_config = "#{RAILS_ROOT}/config/s3.yml" # Alternative location of your s3-config file
|
33
52
|
|
34
53
|
# gzip related configuration
|
35
|
-
config.gzip
|
54
|
+
config.gzip = true # enable gzipped assets (defaults to true)
|
36
55
|
config.gzip_extensions = ['js', 'css'] # only gzip javascript or css (defaults to %w(js css))
|
37
56
|
config.gzip_prefix = "gz" # prefix for gzipped bucket (defaults to "gz")
|
38
57
|
|
39
|
-
config.enabled
|
58
|
+
config.enabled = true if Rails.env.production? # only enable in production
|
40
59
|
end
|
41
60
|
|
42
61
|
## Usage
|
@@ -50,6 +69,14 @@ If the plugin is enabled. Rails' internal `asset_host` and `asset_id` functional
|
|
50
69
|
### Other plugins
|
51
70
|
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.
|
52
71
|
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
Feel free to fork the project and send pull-requests.
|
75
|
+
|
76
|
+
## Known Limitations
|
77
|
+
|
78
|
+
- Does not delete old assets
|
79
|
+
|
53
80
|
## Compatibility
|
54
81
|
|
55
82
|
Tested on Rails 2.3.5 with SASS and AssetPackager plugins
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|