diff options
author | schneems <richard.schneeman@gmail.com> | 2014-08-24 15:44:32 -0500 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2014-08-24 15:44:32 -0500 |
commit | fa704ed6f4568dbabce713f7c4788575e91c09af (patch) | |
tree | d72a33d9013cf39d4f1b872d01774b74952f749b /guides | |
parent | 8c2b3c9178a9628f44c8880ddb8e79f379a54b99 (diff) | |
download | rails-fa704ed6f4568dbabce713f7c4788575e91c09af.tar.gz rails-fa704ed6f4568dbabce713f7c4788575e91c09af.tar.bz2 rails-fa704ed6f4568dbabce713f7c4788575e91c09af.zip |
[ci skip] docs can URL cache invalidation
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/asset_pipeline.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md index 389e64f1b4..c5985ddaf4 100644 --- a/guides/source/asset_pipeline.md +++ b/guides/source/asset_pipeline.md @@ -1094,6 +1094,30 @@ asset for up to a year. Since most CDNs also cache headers of the request, this the browser then knows that it can store this asset for a very long time before needing to re-request it. +##### CDNs and URL based Cache Invalidation + +Most CDNs will cache contents of an asset based on the complete URL. This means +that a request to + +``` +http://mycdnsubdomain.fictional-cdn.com/assets/smile-123.png +``` + +Will be a completely different cache from + +``` +http://mycdnsubdomain.fictional-cdn.com/assets/smile.png +``` + +If you want to set far future `max-age` in your `Cache-Control` (and you do). +Then make sure when you change your assets that your cache is invalidated. For +example when changing the smiley face in an image from yellow to blue, you want +all visitors of your site to get the new blue face. When using a CDN with a the +Rails asset pipeline `config.assets.digest` is set to true by default so that +each asset will have a different file name when it is changed. This way you +don't have to ever manually invalidate any items in your cache. By using a +different unique asset name instead, your users get the latest asset. + Customizing the Pipeline ------------------------ |