0

we are running our Ruby on Rails (4.0) application (call it: 'carwow') on Heroku, url is http://www.carwow.co.uk on our controller response we are setting http caching expire with:

expires_in XXX.seconds, :public => true

Now, let's try running on a ruby console the following code: (you need to run gem install rest-client-components first):

require 'restclient/components'
require 'rack/cache'

RestClient.enable Rack::Cache, :metastore => 'file:/tmp/cache/meta', :entitystore => 'file:/tmp/cache/body'

RestClient.get('http://www.carwow.co.uk'); nil
RestClient.get('http://www.carwow.co.uk'); nil

RestClient.get('https://api.github.com/users/octocat/orgs') ; nil
RestClient.get('https://api.github.com/users/octocat/orgs') ; nil

The second request to 'carwow' will not used any cached version and it will display the following: cache: [GET ] miss, store

The second request to github will display cache: [GET ] fresh

When we run the 'carwow' application locally both in dev and production mode (unicorn server like on Heroku) the second request displays cache: [GET ] fresh

We started believing that there might be something wrong in the way we set HTTP headers but we can't pinpoint the problem. Has anyone ever experienced this?

Kind regards

1 Answers1

0

We fixed it using this option when configuring the client's rack cache:

ignore_headers: ['X-Content-Digest']

More details on the reasons why this fixes it can be found on this post: https://github.com/rtomayko/rack-cache/issues/59