Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sinatra set cache_control to static files in public folder compile error

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.

like image 816
toy Avatar asked Jan 24 '12 01:01

toy


1 Answers

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 {}:

set :static_cache_control, [:public, {:max_age => 300}]

(Or upgrade Ruby.)

like image 70
matt Avatar answered Sep 28 '22 04:09

matt