Sinatra将cache_control设置为公共文件夹中的静态文件编译错误
我不知道为什么,但当我设置此设置时,它无法编译
设置:static_cache_control,[:public,:max_age => 300]
这就是我得到的,
syntax error, unexpected tASSOC, expecting ']' (SyntaxError)
set :static_cache_control, [:public, :max_age => 300]
^
我只想为 css、javaascript 和图像文件设置“expires”标头。
谢谢。
I'm not sure why but when I set this setting it can't compile
set :static_cache_control, [:public, :max_age => 300]
This is what I get
syntax error, unexpected tASSOC, expecting ']' (SyntaxError)
set :static_cache_control, [:public, :max_age => 300]
^
I just want to set "expires" header to css, javaascript and image files.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您使用的是 Ruby 1.8.7。 Sinatra 文档中显示的语法(将数组中的最后一个条目转换为哈希值)似乎是在 Ruby 1.9 中引入的,但在 1.8.7 中并未引入。
尝试用大括号显式包裹哈希条目
{}
:(或升级 Ruby。)
I'm guessing you're using Ruby 1.8.7. It seems that the syntax shown in the Sinatra docs, where the last entry in an array is converted to a hash, was introduced in Ruby 1.9 and isn't in 1.8.7.
Try explicitly wrapping the hash entries with braces
{}
:(Or upgrade Ruby.)