Bypass Rack::Cache for requests coming from a CDN

344 views Asked by At

I have a Rails 3.2 app, deployed to heroku. I use caching with Rack::Cache and Amazon CloudFront.

For Requests that are served via CloudFront (assets, mostly), the caching layer with Rack::Cache is redundant and I'd rather not use it there (memcached on heroku is expensive)

What is a good way to skip Rack::Cache for these requests?

1

There are 1 answers

0
KMannGT On

This blog post helped me http://jackchu.com/blog/2011/09/20/rails-asset-pipeline-content-delivery-networks-and-rack-cache/

I turned rack cache off completely with:

config.middleware.delete Rack::Cache

He also has another suggestion to replace rack cache with rack static for assets only, which still leaves rack cache in place for other requests.