- Using icon fonts, uploaded to S3 and CloudFront points to S3
- Fonts are precompiled and deployed to S3 with asset_sync
- One domain per site (staging and production)
- Need to use multiple domains (
blah.hknow, need to add
- Fonts are not shown when using
- S3 is configured correctly (set response header
Access-Control-Accept-Originto whatever the request header
- CloudFront is caching the files 24 hours by default, which makes sense for most assets
- CloudFront supports custom origin for a pattern (like
image/*.pngto somewhere else like
images.example.comother than default origin like
- If origin set
Cache-Controlheader, then CloudFront would not cache the response at all (Tried with
s-maxage=0, it still caches the response...) (http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html)
- Action: Add a custom origin to your app server, set patterns
/assets/*.svgBehaviors pointing to the custom origin, and continue with Rails part
- Use rack-cors gem
- Set something like this in
This works for HTTP but not HTTPS, since
* is not allowed in
Access-Control-Accept-Origin for HTTPS
You would need to set like this for HTTPS:
I only changed
credentials to true, but this makes the gem to return what is set in header
Origin instead of
But to deal with CloudFront caching, set this in
No caching in CloudFront, but allow caching in user agent (browser)
If you use
Rack::Deflater on your app server (for compressing responses), your font files are also compressed (
Continue from Part 1...
So now you have some default meta tags, but I am sure you have many pages and want unique meta tags on them, right?
So now we need to add more things to allow that.
Step 4 - Add more helper methods
The most commonly changed meta tags are
keywords are not quite useful these days)
Then you can change the helper method in part 1 to:
Of course it's pointless without custom meta tags:
But how do we use it in view template?
We should not call
set_meta_tags with a big hash of meta tags
keywords, OG tags...)
So let's add the last (really) helper method:
Step 5 - Use it!
One line only!
Step 6 - Improve further
I think this is good enough for the moment
But if you got better idea please share :)
My thoughts about putting meta tags on each page for Ruby on Rails.
Without hardcoding strings in templates!
Step 1 - Use MetaTags gem
Use this gem: