Wednesday, June 07, 2017

Possible Rack Cache Issue

I had to remove rack-cache to figure out why articles index page did not display all articles when a user clicked on a tag to get related articles.

First remove the rack-cache gem, delete rack-cache gem in Gemfile and run bundle. To troubleshoot this problem, in production.rb set:

config.assets.compile = true

In your development machine (not production) run:

bundle exec rake assets:precompile returned 1 instead of one of [0]

This gave a clue that there was a reference to rack-cache in application.rb.

rake assets:precompile --trace RAILS_ENV=production
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
LoadError: cannot load such file -- rack/cache Be sure to add rack-cache to your Gemfile


config.action_dispatch.rack_cache = true from application.rb

Redeploy the code and from rails console production in the production machine, run:


to clear the cache. The problem turned out to be not related to rack-cache. At least one of the suspect has been ruled out. I temporarily disabled the find related articles by tag.