[ACCEPTED]-How do I set HTTP Headers in Ruby/Sinatra app, hosted on Heroku?-varnish

Accepted answer
Score: 31

Usually dynamically generated pages have 4 no caching so the

response.headers['Cache-Control'] = 'public, max-age=300'

header is the right starting 3 point.

Try using one of the services at 2 "Use a Web-based service" to see if they show up in the 1 HTTPd header sent back from your site.

Score: 1

You can also access the header fields of 1 the response object with this syntax:

response['Cache-Control'] = 'public, max-age=600'
Score: 0

In Sinatra you can use the cache_control method:

get '/' do
  # Cache for 24 hours
  cache_control :public, max_age: 86400

  # Your magic goes here
end

0

More Related questions