aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2014-08-24 15:44:09 -0500
committerschneems <richard.schneeman@gmail.com>2014-08-24 15:44:09 -0500
commit8c2b3c9178a9628f44c8880ddb8e79f379a54b99 (patch)
treeb926032140656d759032324da40da1f30e0b9406
parent8ea49ec574b627b6936b739478401b43b8fb8aa5 (diff)
downloadrails-8c2b3c9178a9628f44c8880ddb8e79f379a54b99.tar.gz
rails-8c2b3c9178a9628f44c8880ddb8e79f379a54b99.tar.bz2
rails-8c2b3c9178a9628f44c8880ddb8e79f379a54b99.zip
[ci skip] docs CDN Cache-Control behavior
-rw-r--r--guides/source/asset_pipeline.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md
index 3d11d2ba82..389e64f1b4 100644
--- a/guides/source/asset_pipeline.md
+++ b/guides/source/asset_pipeline.md
@@ -1070,6 +1070,30 @@ X-Timer: S1408912125.211638212,VS0,VE0
Check your CDN documentation for any additional information they may provide
such as `X-Cache` or for any headers they may
+##### CDNs and the Cache-Control Header
+
+The [cache control
+header](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9) is a W3C
+specification that describes how a request can be cached. When no CDN is used, a
+browser will use this information to cache contents. This is very helpful for
+assets that are not modified so that a browser does not need to re-download a
+website's CSS or javascript on every request. Generally we want our Rails server
+to tell our CDN (and browser) that the asset is "public", that means any cache
+can store the request. Also we commonly want to set `max-age` which is how long
+the cache will store the object before invalidating the cache. The `max-age`
+value is set to seconds with a maximum possible value of `31536000` which is one
+year. You can do this in your rails application by setting
+
+```
+config.static_cache_control = "public, max-age=31536000"
+```
+
+Now when your application serves an asset in production, the CDN will store the
+asset for up to a year. Since most CDNs also cache headers of the request, this
+`Cache-Control` will be passed along to all future browsers seeking this asset,
+the browser then knows that it can store this asset for a very long time before
+needing to re-request it.
+
Customizing the Pipeline
------------------------