Setting expires headers via Rack by jgn on Friday, March 25, 2011 in Rails and Code

For future reference:

To set expires headers on responses coming from your /assets path:

Add rack-contrib to your Gemfile

In config.ru, before your "run":

[sourcecode language="ruby"] require 'rack/contrib' use Rack::StaticCache, :urls => ['/assets', '/images', '/javascripts'], :root => 'public' [/sourcecode]

The default is one year. For two, add :duration => 2 after the :urls specification.

That is all.

comments powered by Disqus