One of the most rewarding things I've found while playing with Sinatra so far it encourages me to learn more about the implementation of the underlying mechanics of a modern web application. This is a framework that doesn't coddle you: the things that you get for free in Rails and the other larger web frameworks are nowhere to be seen. What's left is lean & mean, and ready to be shaped into whatever form you fancy!
If you're using Sass, you'll no doubt have something like this in your Sinatra app:
get "/stylesheets/screen.css" do content_type 'text/css' sass :"stylesheets/screen" end
When someone requests the
/stylesheets/screen.css file, the above action is run and the generated CSS is sent back. You won't want the very same thing happening for the next page request. You can fix this by setting the 'Expiry' header in the responses you send to stylesheet requests:
get "/stylesheets/screen.css" do content_type 'text/css' response['Expires'] = (Time.now + 60*60*24*356*3).httpdate sass :"stylesheets/screen" end
Setting the 'Expires' header in the above action will encourage client proxies or browsers to cache your generated stylesheet.
These helpers will generate links with a timestamp appended, like so: