JCS*_*CSG 5 caching ruby-on-rails cdn amazon-cloudfront
我是否这样做:
head 302
Run Code Online (Sandbox Code Playgroud)
要么
head 307
Run Code Online (Sandbox Code Playgroud)
要么
redirect_to
Run Code Online (Sandbox Code Playgroud)
调用相同的控制器动作
response.headers['Cache-Control'] = "public, max-age=86400"
Run Code Online (Sandbox Code Playgroud)
没有效果.Rails发送:
Cache-Control: no-cache
Run Code Online (Sandbox Code Playgroud)
无论.我需要发送Cache-Control标头来指示边缘缓存为重定向服务一天.这可能吗?
小智 12
您不能将Cache-Control直接设置到标头中(不再?),因为您需要修改response.cache_control对象(因为它稍后将用于设置Cache-Control标头).
幸运的是,expires_in方法为您解决了这个问题:
expires_in 1.day, :public => true
Run Code Online (Sandbox Code Playgroud)
在这里查看更多:http: //apidock.com/rails/ActionController/ConditionalGet/expires_in
. I need to send the Cache-Control header to instruct an edge cache to serve the redirect for a day.
Run Code Online (Sandbox Code Playgroud)
这怎么可能 ?在临时重定向的情况下,浏览器将始终首先尝试获取原始网址,然后在重定向时尝试其他网址,如果缓存在代理上,则可以从那里提供服务。但浏览器仍然会再次与您的服务器进行第一次联系。
| 归档时间: |
|
| 查看次数: |
8568 次 |
| 最近记录: |