4 ms·
Make Sure Your Rails Application is Actually Caching (and not just pretending)
- atambo 17y agoAnd for those using nginx use this nginx.conf (read the comments for all the details): http://brainspl.at/nginx.conf.txt http://brainspl.at/nginx.conf.txt
- JangoSteve 17y agoThanks! I'll post the link at the bottom of the article.
- atambo 17y agoBtw, I think your website is down? http://downforeveryoneorjustme.com/http://www.alfajango.com/blog/make-sure-your-rails-application-is-actually-caching-and-not-just-pretending/ http://downforeveryoneorjustme.com/http://www.alfajango.com/...
- JangoSteve 17y agoYes it was. Not really sure what happened there, as I could SSH in and all resources seemed to be fine. Weird! At any rate, it's back up now.
- vijaydev 17y agoHN does that to you :)
- andrewvc 17y agoI've actually stopped page caching since switching over to Heroku, and I really like using their HTTP caching with Varnish instead. I love that with HTTP you can cache pages with query strings in them and that time based expiration is easy. Additionally, web proxies can cache your page for users. Additionally, setting up HTTP caching with rails is even easier than setting up page caching if you use Rack::Cache + Memcached (though it isn't as fast as varnish). The bonus advantage of using Rack::Cache is that since its a Rack plugin, it works regardless of the web server config. I can see this being useful for apps meant to be deployed simply at client sites, where admins may not know how to setup a server for Rails.
- eliot_sykes 17y agopage_cache rails plugin that caches pages as a localhost background job to give a holeless cache: http://github.com/eliotsykes/page_cache http://github.com/eliotsykes/page_cache To be sure cached pages are being served, if a non-localhost request makes it through to the Rails app, for a page that should be cached, the plugin throws an exception. Perhaps a bit extreme but gives me peace of mind that the cached pages are always being served. Currently using it on missedconnections.com
- mikeytown2 17y agoSimple solution is to add a html comment to the bottom of the file; that way you can tell if it's from the cache or not. In terms of rewrite rules "inspiration", I recommend taking a peek at the Boost module http://drupal.org/project/boost http://drupal.org/project/boost You should be able to cache all html with just 1 rewrite rule (including query strings), 2 if you want pre-compressed gzip ;)